40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class Fire : MonoBehaviour
|
||
|
{
|
||
|
private float range = 0;
|
||
|
float minFlickerIntensity = 0.5f;
|
||
|
float maxFlickerIntensity = 1.0f;
|
||
|
float flickerSpeed = 4.9f;
|
||
|
private HardLight2D firelight;
|
||
|
private GameObject fire;
|
||
|
private int randomizer = 0;
|
||
|
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
firelight = FindObjectOfType<HardLight2D>();
|
||
|
fire = GameObject.Find("Fire");
|
||
|
StartCoroutine( ChangeRange());
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
StartCoroutine( ChangeRange());
|
||
|
}
|
||
|
|
||
|
IEnumerator ChangeRange()
|
||
|
{
|
||
|
if (randomizer == 0) {
|
||
|
firelight.Intensity = (Random.Range (minFlickerIntensity, maxFlickerIntensity));
|
||
|
}
|
||
|
else firelight.Intensity = (Random.Range (minFlickerIntensity, maxFlickerIntensity));
|
||
|
|
||
|
randomizer = Random.Range (0, 1);
|
||
|
yield return new WaitForSeconds(flickerSpeed);
|
||
|
}
|
||
|
}
|