63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
using UnityEngine;
|
|
|
|
public class UniStormTimeEventExample : MonoBehaviour
|
|
{
|
|
private GameObject uniStormSystem;
|
|
|
|
public float hourOfEvent;
|
|
|
|
public float endHourOfEvent;
|
|
|
|
public bool eventTestBool;
|
|
|
|
public Light lightSource;
|
|
|
|
public int Hour;
|
|
|
|
private void Awake()
|
|
{
|
|
uniStormSystem = GameObject.Find("UniStormSystemEditor");
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (uniStormSystem == null)
|
|
{
|
|
Debug.LogError("<color=red>Null Reference:</color> You must have the UniStorm Editor in your scene and named 'UniStormSystemEditor'. Make sure your C# UniStorm Editor has this name. ");
|
|
}
|
|
Hour = uniStormSystem.GetComponent<UniStormWeatherSystem_C>().hourCounter;
|
|
if (Hour > 6 && Hour < 19)
|
|
{
|
|
lightSource.intensity = 0f;
|
|
lightSource.enabled = false;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!(uniStormSystem != null))
|
|
{
|
|
return;
|
|
}
|
|
Hour = uniStormSystem.GetComponent<UniStormWeatherSystem_C>().hourCounter;
|
|
if ((Hour >= 19 && Hour < 24 && !eventTestBool) || (Hour >= 0 && Hour < 5 && !eventTestBool))
|
|
{
|
|
lightSource.intensity += Time.deltaTime;
|
|
lightSource.enabled = true;
|
|
if (lightSource.intensity >= 2f)
|
|
{
|
|
eventTestBool = true;
|
|
}
|
|
}
|
|
if (Hour > 5 && Hour < 19 && eventTestBool)
|
|
{
|
|
lightSource.intensity -= Time.deltaTime;
|
|
if (lightSource.intensity <= 0f)
|
|
{
|
|
lightSource.enabled = false;
|
|
eventTestBool = false;
|
|
}
|
|
}
|
|
}
|
|
}
|