Пример #1
0
    /// <summary>
    /// Method called when the game is over.
    /// The in game UI is hidden and the game over screen is displayed.
    /// The relevant UI is updated with new values.
    /// The JSON is updated with the new coins collected and the new high score if it has been achieved.
    /// The JSON file is then saved.
    /// </summary>
    void GameOver()
    {
        playing = false;

        HideGameUI();

        DisplayGameOverScreen();

        string text          = "Score: ";
        string gameOverScore = NormaliseScore(score);

        text += gameOverScore;
        gameoverScoreText.text = text;

        parser.AddCoinsCollected(coinsCollected);
        totalCoinsCollected += coinsCollected;

        SetTotalCoinsCollectedText();

        if (score > highScore)
        {
            parser.SetHighScore(score);
            highScore = score;

            newHighscoreText.gameObject.SetActive(true);
        }
        SetHighscoreText();

        parser.SaveJson();
    }