void Update () { switch (gameState) { case gameStates.Playing: if (playerHealth.isAlive == false) { // update gameState gameState = gameStates.Death; // set the end game score gameOverScoreDisplay.text = mainScoreDisplay.text; // switch which GUI is showing mainCanvas.SetActive (false); gameOverCanvas.SetActive (true); } else if (canBeatLevel && score>=beatLevelScore) { // update gameState gameState = gameStates.BeatLevel; // hide the player so game doesn't continue playing player.SetActive(false); // switch which GUI is showing mainCanvas.SetActive (false); beatLevelCanvas.SetActive (true); } break; case gameStates.Death: backgroundMusic.volume -= 0.01f; if (backgroundMusic.volume<=0.0f) { AudioSource.PlayClipAtPoint (gameOverSFX,gameObject.transform.position); gameState = gameStates.GameOver; } break; case gameStates.BeatLevel: backgroundMusic.volume -= 0.01f; if (backgroundMusic.volume<=0.0f) { AudioSource.PlayClipAtPoint (beatLevelSFX,gameObject.transform.position); gameState = gameStates.GameOver; } break; case gameStates.GameOver: // nothing break; } }