2023-01-10 04:21:36 +01:00
|
|
|
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;
|
2023-01-13 14:11:01 +01:00
|
|
|
private HardLight2D[] lights;
|
2023-01-10 04:21:36 +01:00
|
|
|
private GameObject fire;
|
|
|
|
private int randomizer = 0;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2023-01-13 14:11:01 +01:00
|
|
|
|
|
|
|
lights = FindObjectsOfType<HardLight2D>();
|
|
|
|
List<HardLight2D> finalList = new List<HardLight2D>();
|
|
|
|
string nameToLookFor = "LightFire";
|
|
|
|
|
|
|
|
for(var i = 0; i < lights.Length; i++)
|
|
|
|
{
|
|
|
|
if(lights[i].name == nameToLookFor)
|
|
|
|
{
|
|
|
|
finalList.Add(lights[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
firelight = finalList[0];
|
|
|
|
|
|
|
|
//firelight = FindObjectOfType<HardLight2D>();
|
2023-01-10 04:21:36 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|