コード例 #1
0
    private IEnumerator GameOverCoroutine()
    {
        GameIsOver = true;
        mouseAndTouchManager.SetInputEnabled(false);
        movementButtons.SetActive(false);
        musicManager.EndMusic();
        soundEffectManager.PlayEffect("Die");

        yield return(new WaitForSeconds(gameOverDelay));

        gameOverPanel.SetActive(true);
        int topScore   = PlayerPrefs.GetInt("Top Score");
        int finalScore = scoreCounter.Score;

        // 0 can't be a top score because they haven't scored anything.
        if (topScore > 0)
        {
            if (finalScore > topScore)
            {
                finalScoreText.text = "New record!\nYour score: " + finalScore + "\nPrevious top score: " + topScore;
                PlayerPrefs.SetInt("Top Score", finalScore);
            }
            else
            {
                finalScoreText.text = "Your score: " + finalScore + "\nTop score: " + topScore;
            }
        }
        else
        {
            finalScoreText.text = "Your score: " + finalScore;
            PlayerPrefs.SetInt("Top Score", finalScore);
        }
    }
コード例 #2
0
    public void GameOver()
    {
        trackObjectManager.TargetMoveSpeed = 0f;
        gameIsInProgress = false;
        mouseAndTouchManager.SetInputEnabled(false);
        movementButtons.SetActive(false);

        StartCoroutine(GameOverCoroutine());
    }