void Update() { switch (UIState) { case GameUIState.MAINMENU: if (Input.GetButtonDown("Cancel")) { ExitGame(); } break; case GameUIState.INGAME: if (Input.GetButtonDown("Cancel")) { panels.ShowPausePanel(true); //Call the DoPause function to pause the game DoPause(); } if (player) { if (player.IsDead()) { Timer timing = GameObject.FindObjectOfType <Timer> (); if (timing) { playerTime = string.Format("{0:00} : {1:00} AM", timing.minutes, timing.seconds); } UIState = GameUIState.GAMEOVER; } } break; case GameUIState.PAUSED: mixer.SetFloat("MasterVolume", -80); if (Input.GetButtonDown("Cancel")) { panels.ShowPausePanel(false); //Call the UnPause function to unpause the game UnPause(); } break; case GameUIState.GAMEOVER: if (hasWon) { mixer.SetFloat("MelodyVolume", 0); mixer.SetFloat("HorrorVolume", -80); } else { mixer.SetFloat("MelodyVolume", -80); mixer.SetFloat("HorrorVolume", 0); } mixer.SetFloat("NoiseVolume", -80); GamingOver(); panels.ShowGameOverPanel(true); if (Input.GetButtonDown("Cancel")) { panels.ShowPausePanel(true); //Call the DoPause function to pause the game DoPause(); } break; } }