// Use this for initialization void Start() { Date currentDate = clock.getCurrentDate(); GetInitialSeason(currentDate); currentTime = clock.getCurrentTime(); if (debug) { Debug.Log(this.name); Debug.Log("Current season: " + currentSeason); Debug.Log("start date: " + currentSeason.GetStartDate()); Debug.Log("current date: " + currentDate); Debug.Log("current time: " + currentTime); } Date transitionInEnd = currentSeason.GetStartDate().DateWithDays(transiotion_days); if (debug) { Debug.Log("TransitionIn end: " + transitionInEnd); } //TODO: transiotion_days/2 es resultado de division entera, si se mete un numero de dias impar faltará un dia en la transicion. habra que hacer comprobaciones o algo, pero no antes de la presentacion, que hay prisa if (currentDate.CompareTo(transitionInEnd) < 0) { phase = TRANSITION_IN; previousSeason = GetPreviousSeason(currentSeason); //TODO: hay que implementar el modo de recuperar la estacion anterior ChangeColor(currentSeason.GetStartDate().DaysBetween(currentDate), currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()); if (debug) { Debug.Log(" initial state detected to be transitioning in from season " + previousSeason.name); Debug.Log("time since the season change: " + (currentSeason.GetStartDate().DaysBetween(currentDate)) + " days and " + (currentTime.GetHours() * 3600 + currentTime.GetMinutes() * 60 + currentTime.GetSeconds()) + "Seconds"); Debug.Break(); } } else { phase = WAITING; previousSeason = currentSeason; ChangeColor(0, 0); if (debug) { Debug.Log(" initial state detected to be waiting to season " + currentSeason.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; } }