コード例 #1
0
    private void OnMenuButtonClick()
    {
        GameDetailsUI.SetActive(false);
        scorePauseText.text = "SCORE: " + score.ToString();

        if (currentLevel == Levels.maxLevels)
        {
            highScorePauseText.text = "HIGH SCORE: " + highScore.ToString();
        }
        else
        {
            highScorePauseText.text = "MAX SCORE: " + highScore.ToString();
        }

        if (Bird.gameStatus == Bird.GameStatus.DEAD)
        {
            gameOverText.text   = "OOPS! BIRD DIED";
            tapToStartText.text = "FLAP TO RESTART";
        }
        else if (Bird.gameStatus == Bird.GameStatus.PAUSED)
        {
            gameOverText.text   = "GAME PAUSED";
            tapToStartText.text = "TAP TO CONTINUE";
        }
        else
        {
            gameOverText.color  = new Color32(0, 204, 0, 255);
            gameOverText.text   = "LEVEL COMPLETED";
            tapToStartText.text = "TAP TO CONTINUE";
        }

        PauseUI.SetActive(true);
        Time.timeScale = 0f;
    }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (Bird.gameStatus == Bird.GameStatus.DEAD || Bird.gameStatus == Bird.GameStatus.UPGRADING || Bird.gameStatus == Bird.GameStatus.PAUSED)
     {
         OnMenuButtonClick();
         if (Input.GetMouseButtonDown(0))
         {
             if (Input.mousePosition.y < dispalyHeight && Input.mousePosition.x < displayWidth)
             {
                 if (Bird.gameStatus != Bird.GameStatus.PAUSED)
                 {
                     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                 }
                 else
                 {
                     GameDetailsUI.SetActive(true);
                     PauseUI.SetActive(false);
                     Bird.gameStatus = Bird.GameStatus.PLAYING;
                 }
                 Time.timeScale = 1f;
             }
         }
     }
 }