// Update is called once per frame void Update() { timeText.text = clock.getCurrentTime().ToString(); dateText.text = clock.getCurrentDate().ToString(); SeasonText.text = clock.GetSeason().name; sunsetAndSunrise.text = "Sunrise: " + clock.getSunriseTime().ToString() + "\tSunset: " + clock.getSunsetTime().ToString(); weatherStateText.text = weatherController.ToString(); }
// Update is called once per frame void Update() { currentTime = clock.getCurrentTime(); Date currentDate = clock.getCurrentDate(); currentSeason = clock.GetSeason(); Date transitionInEnd = currentSeason.GetStartDate().DateWithDays(transiotion_days); switch (phase) { case TRANSITION_IN: if (currentDate.CompareTo(transitionInEnd) > 0) { phase = WAITING; if (debug) { Debug.Log(" detected the end of the transitioning in phase, now waiting in season: " + currentSeason.ToString()); Debug.Log("time since the season change: " + (transitionInEnd.DaysBetween(currentDate)) + " days and " + (currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()) + "Seconds"); Debug.Break(); } ChangeColor(0, 0); previousSeason = currentSeason; } else { if (debug) { Debug.Log(" transitioning into season " + currentSeason); Debug.Log("time since the season change: " + (currentSeason.GetStartDate().DaysBetween(currentDate)) + " days and " + (currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()) + "Seconds"); Debug.Break(); } ChangeColor(currentSeason.GetStartDate().DaysBetween(currentDate), currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()); } break; case WAITING: //if (debug) { // Debug.Log("current season: " + currentSeason + "\t previousSeason :" + previousSeason + "\n" + // "index match: " + (currentSeason.GetIndex() != previousSeason.GetIndex())); // Debug.Break(); //} if (currentSeason.GetIndex() != previousSeason.GetIndex()) { phase = TRANSITION_IN; if (debug) { Debug.Log(" reached end of season: \n" + "current season: " + currentSeason.ToString() + "\t previousSeason :" + previousSeason.ToString() + "\n phase: " + phase); Debug.Break(); } ChangeColor(currentSeason.GetStartDate().DaysBetween(currentDate), currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()); } break; } }
void Update() { if (lastUpdate.SecondsBetween(clock.getCurrentTime()) >= update_frequency * 60) { if (debug) { Debug.Log("It is time to calculate a new weather state"); Debug.Break(); } if (!(clock.GetSeason().GetIndex() == currentSeasonIndex)) { currentSeasonIndex = clock.GetSeason().GetIndex(); updateAcumulativeValues(currentSeasonIndex); } currentState = getNextState(currentState); lastUpdate = clock.getCurrentTime().Clone(); visualizeState(); } }
// Update is called once per frame void Update() { //Debug.Break(); currentSeason = clock.GetSeason(); if (!(currentSeason.GetIndex() == previousSeason.GetIndex())) { if (debug) { Debug.Log("New Season detected, updating models....."); } for (int i = 0; i < models.Length; i++) { if (currentSeason.GetIndex() == i) { models[i].SetActive(true); if (debug) { Debug.Log("Model in position " + i + "set to active"); } } else { models[i].SetActive(false); if (debug) { Debug.Log("Model in position " + i + "set to not active"); } } } if (debug) { Debug.Break(); } previousSeason = currentSeason; } }
void Update() { currentTime = clock.getCurrentTime(); currentSeason = clock.GetSeason(); float opacity; Time midnight = clock.GetMidnightTime(); switch (phase) { case FADING_IN: if (midnight.SecondsBetween(currentTime) >= minutesToFade * 60) { phase = SHINING; if (debug) { Debug.Log("end of the fasing_in period detected, phase set to " + phase + " SHINING \n" + "Seconds since midnight: " + midnight.SecondsBetween(currentTime) + "opacity per second: " + opacityChangePerSecond + "Opacity set to: " + 1); Debug.Break(); } setOpacity(1); } else { opacity = midnight.SecondsBetween(currentTime) * opacityChangePerSecond; setOpacity(opacity); } break; case FADING_OUT: if (midnight.SecondsBetween(currentTime) >= minutesToFade * 60) { phase = FADED; if (debug) { Debug.Log("end of the fasing_out period detected, phase set to " + phase + " FADED \n" + "Seconds since midnight: " + midnight.SecondsBetween(currentTime) + "opacity per second: " + opacityChangePerSecond + "Opacity set to: " + 0); Debug.Break(); } setOpacity(0); } else { opacity = 1 - midnight.SecondsBetween(currentTime) * opacityChangePerSecond; setOpacity(opacity); } break; case SHINING: if (previousSeason != currentSeason) { previousSeason = currentSeason; if (currentSeason.GetIndex() == fade_end.GetIndex()) { phase = FADING_OUT; opacity = 1 - midnight.SecondsBetween(currentTime) * opacityChangePerSecond; if (debug) { Debug.Log("Fading_out season start detected, phase set to " + phase + " FADING_OUT \n" + "Seconds since midnight: " + midnight.SecondsBetween(currentTime) + "opacity per second: " + opacityChangePerSecond + "Opacity set to: " + opacity); Debug.Break(); } setOpacity(opacity); } } break; case FADED: if (previousSeason != currentSeason) { previousSeason = currentSeason; if (currentSeason.GetIndex() == fade_start.GetIndex()) { phase = FADING_IN; opacity = midnight.SecondsBetween(currentTime) * opacityChangePerSecond; if (debug) { Debug.Log("Fading in season start detected, phase set to " + phase + " FADING_IN \n" + "Seconds since midnight: " + midnight.SecondsBetween(currentTime) + "opacity per second: " + opacityChangePerSecond + "Opacity set to: " + opacity); Debug.Break(); } setOpacity(opacity); } } break; } previousTime = currentTime.Clone(); }