Пример #1
0
 private void updateTime()
 {
     if (timeLeft > 0)
     {
         timeLeft         -= Time.deltaTime;
         timeLeftText.text = timeLeft.ToString();
     }
     else
     {
         gameOver = true;
         ResultScreen resultScreen = (ResultScreen)ViewHandler.Instance.Show(ViewNames.RESULT_SCREEN_NAME);
         resultScreen.SetResult(currentLevel, currentScore, correctMatches, incorrectMatches);
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (this.gameOver || this.gamePaused)
        {
            return;
        }

        this.ticks += Time.deltaTime;
        if (this.ticks >= 1.0f)
        {
            this.ticks = 0;

            this.timeLeft--;
            this.timerText.text = "TIME LEFT: " + this.timeLeft;

            if (this.timeLeft <= 0.0f)
            {
                //stop game
                this.gameOver = true;
                ResultScreen resultScreen = (ResultScreen)ViewHandler.Instance.Show(ViewNames.RESULT_SCREEN_NAME);
                resultScreen.SetResult(GameMechanicHandler.Instance.GetCurrentLevel(), this.score, this.correctMatches, this.wrongMatches);
            }
        }
    }