// Update is called once per frame void Update() { TimeTillUpdate -= Time.deltaTime; if (CitySatisfaction <= 0) { if (!FailedPanel.activeSelf) { CitySatisfaction = 0; CitySatisfactionSlider.value = 0; CitySatisfactionText.text = CitySatisfaction.ToString() + "%"; FillAreaImage.color = Color.Lerp(GameMurkyGrey, GameYellow, CitySatisfaction / 100.0f); Time.timeScale = 0; int CurrentDay = timerManager.CurrentDay; FailedPanel.SetActive(true); float previousCurrentDay = SaveLoadHighScore.Load(); if (CurrentDay > previousCurrentDay) { SaveLoadHighScore.Save(CurrentDay); HighScoreHeading.text = "New High Score: "; HighScoreText.text = CurrentDay.ToString() + " Day(s)"; } else { HighScoreText.text = previousCurrentDay.ToString() + " Day(s)"; } } // SaveLoadHighScore.Save(CitySatisfaction); } }
void Update() { if (!bTutorial) { timeElapsed += Time.deltaTime; if (timeElapsed >= 2.0f) { timeElapsed = 0.0f; time = time.AddMinutes(MinutesToAdd * 15); TimerText.text = time.ToShortTimeString(); if (time.ToShortTimeString().Equals("6:00 a.m.")) { DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x, new Color(0.8014706f, 0.5852523f, 0.5181363f, 1.0f), 1); } else if (time.ToShortTimeString().Equals("8:00 a.m.")) { DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x, new Color(1.0f, 1.0f, 1.0f, 1.0f), 1); foreach (MeshRenderer rend in tileManager.m_EmissiveTiles) { rend.enabled = false; } } else if (time.ToShortTimeString().Equals("6:00 p.m.")) { DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x, new Color(0.7352941f, 0.4541522f, 0.5181363f, 1.0f), 1); } else if (time.ToShortTimeString().Equals("8:00 p.m.")) { DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x, new Color(0.075f, 0.11f, 0.242f, 1.0f), 1); foreach (MeshRenderer rend in tileManager.m_EmissiveTiles) { rend.enabled = true; } } if (time.ToShortTimeString().Equals("7:00 p.m.")) { // NIGHTTIME MinutesToAdd = 2; Camera.main.GetComponents <AudioSource>()[0].DOFade(0.0f, 1.0f); Camera.main.GetComponents <AudioSource>()[1].Play(); Camera.main.GetComponents <AudioSource>()[1].DOFade(0.7f, 1.0f); GetComponent <AudioSource>().Play(); } else if (time.ToShortTimeString().Equals("7:00 a.m.")) { // DAYTIME MinutesToAdd = 1; Camera.main.GetComponents <AudioSource>()[0].DOFade(1.0f, 1.0f); Camera.main.GetComponents <AudioSource>()[1].DOFade(0.0f, 1.0f); } } if (time.ToShortTimeString().Equals("7:00 p.m.")) { DayTime = false; t = 0; } else if (time.ToShortTimeString().Equals("8:00 a.m.")) { DayTime = true; t = 0; } if (!DayTime) { IssuesManager.Daytime = false; foreach (SpriteRenderer OneCloud in Allclouds) { OneCloud.DOFade(0.0f, 0.2f); } foreach (SpriteRenderer OneStar in Allstars) { OneStar.DOFade(1.0f, 2.0f); } if (t < 1) { // while t below the end limit... // increment it at the desired rate every update: t += Time.deltaTime / duration; } lerpColor = Color.Lerp(DayTimeColor, NightTimeColor, t); RenderSettings.skybox.SetColor("_Tint", lerpColor); } else { IssuesManager.Daytime = true; foreach (SpriteRenderer OneCloud in Allclouds) { OneCloud.DOFade(1.0f, 2.0f); } foreach (SpriteRenderer OneStar in Allstars) { OneStar.DOFade(0.0f, 0.2f); } if (t < 1) { // while t below the end limit... // increment it at the desired rate every update: t += Time.deltaTime / duration; } lerpColor = Color.Lerp(NightTimeColor, DayTimeColor, t); RenderSettings.skybox.SetColor("_Tint", lerpColor); } if (!bHasDayFinished && time.ToShortTimeString().Equals("12:00 a.m.") || time.ToShortTimeString().Equals("12:15 a.m.")) { bHasDayFinished = true; // Add population iPopulation *= 1.02f; PopulationText.text = iPopulation.ToString(); // Add currency Money.AddMoney(200.0f); // close all issues IssuesManager.ResetIssues(); tileManager.ResetRubbish(); RubbishTruckController rubbishTruck = FindObjectOfType <RubbishTruckController>(); if (rubbishTruck) { Destroy(rubbishTruck.gameObject); } // reset contractors for (int i = 0; i < AllHQs.Length; ++i) { AllHQs[i].RemoveContractors(); } Time.timeScale = 0; Transform[] gos = EffectsObject.GetComponentsInChildren <Transform>(); for (int i = 1; i < gos.Length; ++i) { Destroy(gos[i].gameObject); } DayCompletedCanvas.SetActive(true); int iJobsCompletedDay = 0; for (int i = 0; i < 4; ++i) { iJobsCompletedDay += AllHQs[i].JobsCompletedForDay; AllHQs[i].JobsCompletedForDay = 0; } AucklandersHelpedText.text = iJobsCompletedDay.ToString(); MostLiveableText.text = CitySatisfaction.GetCitySatisfaction().ToString() + "%"; DayHeaderText.text = "Congratulations! You Finished Day " + CurrentDay.ToString(); float citySatisfaction = CitySatisfaction.GetCitySatisfaction(); SaveLoadHighScore.Save(citySatisfaction); FeedbackText.text = ""; if (CurrentDay == 1) { if (citySatisfaction < 10.0f) { FeedbackText.text = "Rough first day huh? Better luck tomorrow, you can do this!"; } else if (citySatisfaction < 25.0f) { FeedbackText.text = "Not bad for a first day!"; } else if (citySatisfaction < 50.0f) { FeedbackText.text = "Good job on increasing Auckland's Liveability so quickly!"; } else if (citySatisfaction < 75.0f) { FeedbackText.text = "Well on the way to being the most Liveable City! First day on the job, too!"; } } else if (CurrentDay < 5) { if (citySatisfaction < 10.0f) { FeedbackText.text = "Hm, Auckland doesn't seem very happy with how you're managing this."; } else if (citySatisfaction < 25.0f) { FeedbackText.text = "Not too bad, but definitely not the most liveable city in the world..."; } else if (citySatisfaction < 50.0f) { FeedbackText.text = "Aucklanders are happy - but they could be happier! Can you increase the rating tomorrow?"; } else if (citySatisfaction < 75.0f) { FeedbackText.text = "Well on the way to being the most Liveable City!"; } else if (citySatisfaction < 100.0f) { FeedbackText.text = "Aucklanders are happier than ever - nearly the most Liveable City in the World!"; } else { FeedbackText.text = "Wow! You've helped make Auckland the World's Most Liveable City! "; } } else { if (citySatisfaction < 10.0f) { FeedbackText.text = "You survived 5 days - just!"; } else if (citySatisfaction < 25.0f) { FeedbackText.text = "You survived 5 days, but Aucklanders are pretty disgruntled..."; } else if (citySatisfaction < 50.0f) { FeedbackText.text = "Aucklanders are happy - but they could be happier!"; } else if (citySatisfaction < 75.0f) { FeedbackText.text = "Well on the way to being the most Liveable City!"; } else if (citySatisfaction < 100.0f) { FeedbackText.text = "Aucklanders are happier than ever - nearly the most Liveable City in the World!"; } else { FeedbackText.text = "Wow! You've helped make Auckland the World's Most Liveable City! "; } } CurrentDay++; DayText.text = "Day " + CurrentDay.ToString(); int newNumProblems = (int)(iPopulation / ProblemsPerPop + 0.95f * OldNumProblems); OldNumProblems = newNumProblems; IssuesManager.StartNewDay(newNumProblems, 23); } } }