//Called when the game ends i.e the player loses all their lives public void GameOver() { HighscoresContainer highscoresContainer = FindObjectOfType <HighscoresContainer>(); BlockOfAliens blockOfAliens = FindObjectOfType <BlockOfAliens>(); FlyingSaucer flyingSaucer = FindObjectOfType <FlyingSaucer>(); int numHighscores = highscoresContainer.GetNumberOfHighScores(); int lowestScore = highscoresContainer.GetLowestScore(); //If there are less than 10 highscores or the player got a score greater than the lowest high score //Then the player has just got a highscore so... if (numHighscores < 10 || score > lowestScore) { //Stop the aliens and flying saucer from moving blockOfAliens.SetPaused(true); flyingSaucer.gameObject.SetActive(false); //Make the add score panel active and give the add score script the new score addScore.gameObject.SetActive(true); addScore.SetScore(score); } //Else the player didnt get a high score so... else { //Stop the aliens and flying saucer from moving blockOfAliens.SetPaused(true); flyingSaucer.gameObject.SetActive(false); //Display the game over panel gameOver.SetActive(true); } //Pause the game Time.timeScale = 0f; }