void Update()
{
if (_dayMorningNight == true) {
_HudstatsRight.GetComponent<Text> ().text = "DAY\n" + "- " + _days + " -";
}
if (_dayMorningNight == false) {
_HudstatsRight.GetComponent<Text> ().text = "NIGHT\n" + "- " + _days + " -";
}
// Updates the sun's rotation and intensity according to the current time of day.
UpdateSun ();
// This makes currentTimeOfDay go from 0 to 1 in the number of seconds we've specified.
currentTimeOfDay += (Time.deltaTime / secondsInFullDay) * timeMultiplier;
// If currentTimeOfDay is 1 (midnight) set it to 0 again so we start a new day.
if (currentTimeOfDay >= 1) {
_days ++;
currentTimeOfDay = 0;
}
//Day or night detection
if (currentTimeOfDay > 0.22f && currentTimeOfDay < 0.73f) {
_dayMorningNight = true;
} else {
_dayMorningNight = false;
}
//Sand effect activation
if (_dayMorningNight == true) {
_sandEffect.SetActive (true);
if (_PointLightNight.GetComponent<Light> ().intensity <= 0) {
_PointLightNight.GetComponent<Light> ().intensity = 0;
} else {
_PointLightNight.GetComponent<Light> ().intensity -= 0.8f * Time.deltaTime;
}
}
if (_dayMorningNight == false) {
_sandEffect.SetActive (false);
if (_PointLightNight.GetComponent<Light> ().intensity >= 1.5f) {
_PointLightNight.GetComponent<Light> ().intensity = 1.5f;
} else {
_PointLightNight.GetComponent<Light> ().intensity += 0.8f * Time.deltaTime;
}
}
}