private void Update() { if (firstResidentialPlaced) { timer += Time.deltaTime; switch (stage) { case Stage.Home: if (timer > commuteToWorkTime) { foreach (Resident resident in residents) { resident.SetGoal(Resident.Status.Work); } stage = Stage.CommutingToWork; StartCoroutine(clock.UpdateText("To Work!")); } break; case Stage.CommutingToWork: if (timer > assertWorkTime) { if (successfulDailyCommutes == 0) { StartCoroutine(SkipToHome()); } Stack <Resident> residentStack = new Stack <Resident>(residents); while (residentStack.Count > 0) { Resident resident = residentStack.Pop(); resident.AssertWork(); } stage = Stage.Working; StartCoroutine(clock.UpdateText("At Work")); } break; case Stage.Working: if (timer > commuteHomeTime) { foreach (Resident resident in residents) { resident.SetGoal(Resident.Status.Home); } stage = Stage.CommutingToHome; StartCoroutine(clock.UpdateText("To Home!")); } break; case Stage.CommutingToHome: if (timer > assertHomeTime) { Stack <Resident> residentStack = new Stack <Resident>(residents); while (residentStack.Count > 0) { Resident resident = residentStack.Pop(); resident.AssertHome(); } stage = Stage.Home; StartCoroutine(clock.UpdateText("At Home")); timer = 0f; if (!won && successfulDailyCommutes >= goalCommutes) { Win(); } else { StartCoroutine(DailyCommutesAnimation()); } } break; default: break; } } if (commutesTextAnimationTimer > 0f) { commutesTextAnimationTimer -= Time.unscaledDeltaTime * 5f; if (commutesTextAnimationTimer > .5f) { successfulDailyCommutesText.transform.localScale = Vector3.one * Mathf.Lerp(0f, 1.25f, (1f - commutesTextAnimationTimer) / .5f); } else { successfulDailyCommutesText.transform.localScale = Vector3.one * Mathf.Lerp(1.25f, 1f, (.5f - commutesTextAnimationTimer) / .5f); } } if (Input.GetKeyDown(KeyCode.Escape)) { if (activeWindow != pauseWindow) { pauseWindow.Show(); } else { pauseWindow.Hide(); } } }