Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!mrStuntman.hasFallen)
        {
            // Simulate touch events from mouse events
            HandleTouchInput();

            stepTimeDelta += Time.deltaTime;

            if (stepTimeDelta >= stepRate)
            {
                stepTimeDelta = 0f;
                steps++;
                UpdateSteps();
            }
        }
        else
        {
            // Allow Mr Stuntman to fall before displaying game over or high score
            mrStuntman.GetComponent <BoxCollider2D>().enabled = false;
            fallTimer -= Time.deltaTime;
            if (fallTimer <= 0.0f)
            {
                // Stop the animations
                Time.timeScale = 0f;
                UpdateSteps();
                fallTimer = 2f;
                if (highScoreController.IsNewHighScore(steps))
                {
                    nhsScoreText.text += "\n" + steps.ToString();
                    highScorePanel.SetActive(true);
                }
                else
                {
                    goScoreText.text += "\n" + steps.ToString();
                    gameOverPanel.SetActive(true);
                }
            }
        }
    }