示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (trigger.getPoint() == true)
        {
            updateUI.updateScore();
            updateUI.UpdateCoinsLeft();
            trigger.setPoint(false);
        }

        if (trigger.getPowerState() == true)
        {
            timeleft += Time.deltaTime;
            print("Time Left: " + timeleft);
            updateUI.UpdateTime(powerUpduration - timeleft);
            if (timeleft >= powerUpduration)
            {
                trigger.setPowerStat(false);
                timeleft = 0;
            }
        }

        if (trigger.isDeadState() == true)
        {
            print("Player is dead");
            endScreen.SetActive(enabled);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        //d   Debug.Log("getpoint() = true");
        if (trigger.getPoint() == true) //when player gets a point
        {
            updateUI.updateScore();
            updateUI.UpdateCoinsLeft();
            trigger.setPoint(false);
        }
        // Debug.Log("getpoint successful");
        if (trigger.getPowerState() == true) //when player has a power up, set a count down
        {
            timeleft += Time.deltaTime;

            // updateUI.UpdateTime( powerUpduration - timeleft);
            updateUI.UpdateEnergyBar(powerUpduration - timeleft, powerUpduration);
            if (timeleft >= powerUpduration)
            {
                trigger.setPowerStat(false);
                timeleft = 0;
            }
            if (timeleft <= powerUpduration && trigger.getResetPowerup() == true)
            {
                timeleft = 0;
                trigger.setResetPowerup(false);
            }
        }

        if (trigger.isDeadState() == true) //when player is dead, game over screen activates
        {
            //  print("Player is dead");
            GameOverScreen.SetActive(true);
            Time.timeScale = 0;

            if (controltype.getVibration())
            {
                Debug.Log("Vibrate");
                Handheld.Vibrate();
            }
        }

        if (updateUI.PlayerWins == true && end == false) //when player wins, stops game from running
        {
            //GetComponent<CanvasManager>().disablePauseMenu();
            WinScreen.SetActive(true);
            timetext.text  = "Time Taken: " + TimeTaken.ToString("0.00");
            end            = true;
            Time.timeScale = 0;
        }
        TimeTaken += Time.deltaTime; //time taken throughout the game
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (trigger.getPoint() == true) //when player gets a point
        {
            updateUI.updateScore();
            updateUI.UpdateCoinsLeft();
            trigger.setPoint(false);
        }

        if (trigger.getPowerState() == true) //when player has a power up, set a count down
        {
            timeleft += Time.deltaTime;

            // updateUI.UpdateTime( powerUpduration - timeleft);
            updateUI.UpdateEnergyBar(powerUpduration - timeleft, powerUpduration);
            if (timeleft >= powerUpduration)
            {
                trigger.setPowerStat(false);
                timeleft = 0;
            }
            if (timeleft <= powerUpduration && trigger.getResetPowerup() == true)
            {
                timeleft = 0;
                trigger.setResetPowerup(false);
            }
        }

        if (trigger.isDeadState() == true) //when player is dead, recieving end screen alert
        {
            print("Player is dead");
            endScreen.SetActive(true);
            Time.timeScale = 0;

            /*
             * if (controltype.getVibration())
             * {
             *  Handheld.Vibrate();
             * }
             */
        }

        if (updateUI.PlayerWins == true && end == false)
        {
            WinScreen.SetActive(true);
            timetext.text  = "Time Taken: " + TimeTaken.ToString("0.00");
            end            = true;
            Time.timeScale = 0;
        }
        TimeTaken += Time.deltaTime; //time taken throughout the game
    }