IEnumerator TimeCoroutine() { while (true) { timeOfDay += 0.5f / speed; timeOfDay %= 24; UpdateLights(timeOfDay / 24f); if (sunIsOut == false && dayPhase == timePhases.MORNING) { DayTime(); } else if (sunIsOut == true && dayPhase == timePhases.NIGHT) { NightTime(); } switch (Mathf.Floor(timeOfDay)) { case 6: dayPhase = timePhases.MORNING; break; case 12: dayPhase = timePhases.AFTERNOON; break; case 16: dayPhase = timePhases.EVENING; break; case 20: dayPhase = timePhases.NIGHT; break; } todSO.time = timeOfDay; todSO.phase = dayPhase.ToString(); yield return(new WaitForSeconds(0.25f)); } }
private void Awake() { NightTime(); dayPhase = timePhases.NIGHT; sunIsOut = false; }