public void UpdateInfoBar() { // Change the label to match the current date infoBar.DateLabel.GetComponent <TMPro.TMP_Text>().SetText(DateFuncs.DateToString(curDate)); // Change the season and weather label string weatherSeasonLabel = string.Format("{0} - {1}", curSeason, ClimateFuncs.WeatherToString(curWeather)); infoBar.WeatherSeasonLabel.GetComponent <TMPro.TMP_Text>().SetText(weatherSeasonLabel); }
// Runs at the end of each day public IEnumerator EndDay(float waitTime = 0f) { yield return(new WaitForSeconds(waitTime)); yield return(new WaitForEndOfFrame()); // All of these WaitForEndOfFrames are so that the LogSpaces show up properly. curDate = DateFuncs.NextDay(curDate); curWeather = ClimateFuncs.GetNextWeather(curWeather, curDate); curSeason = ClimateFuncs.GetSeason(curDate); LogSpace(); // Get rid of dead citizens bool buriedSomeone = false; for (int i = 0; i < citizens.Count; i++) { if (citizens[i].isDead) { citizens[i].Bury(); buriedSomeone = true; i--; } } if (buriedSomeone) { LogSpace(); } // A new citizen moves in each day if there's space. if (citizens.Count < maxCitizens) { citizens.Add(SpawnCitizen()); yield return(new WaitForEndOfFrame()); LogSpace(); } yield return(new WaitForEndOfFrame()); UpdateInfoBar(); LogMessage("A new day has begun.\n ", "Peach"); // Do upkeep for living citizens foreach (CitizenScript citizen in citizens) { if (!citizen.isDead) { citizen.Upkeep(); LogSpace(); } } LogMessage("The day has ended.", "Blue"); // Clear excess items from shop, oldest items go first. GetComponent <ShopScript>().ClearExcess(); // The responsible thing to do would be clearing old event messages after a certain point, // otherwise it will quickly eat up all of the computer's memory. int excessMessages = eventLog.transform.childCount - maxEvtLogMessages; for (int i = 0; i < excessMessages; i++) { if (eventLog.transform.childCount > maxEvtLogMessages) { Destroy(eventLog.transform.GetChild(i).gameObject); } } GameObject newDay = Instantiate(evtLogTxtTemplate, eventLog.transform); curDayTextObject = newDay; curDayTextObject.GetComponent <TMPro.TMP_Text>().SetText(""); Canvas.ForceUpdateCanvases(); if (scrollToBottomOnNewDay) { eventLog.GetComponentInParent <ScrollRect>().verticalNormalizedPosition = 0; } }