// Update is called once per frame
    void Update()
    {
        if (!battleStarted && !banner.isAnimating)
        {
            battleStarted = true;

            player1.enable = true;
            player2.enable = true;

            GameUtils.playSound(backgroundMusic, musicPlayer);
        }

        if (battleStarted && !battleEnded)
        {
            if (roundTime > 0 && Time.time - lastTimeUpdate > 1)
            {
                roundTime--;
                lastTimeUpdate = Time.time;
                if (roundTime == 0)
                {
                    expireTime();
                }
            }

            if (player1.healtPercent <= 0)
            {
                banner.showYouWin(player2.name);
                // banner.showYouLose ();
                battleEnded = true;
            }
            else if (player2.healtPercent <= 0)
            {
                banner.showYouWin(player1.name);
                battleEnded = true;
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        if (!battleStarted)
        {
            battleStarted = true;

            player1.enable = true;
            player2.enable = true;
        }

        if (battleStarted && !battleEnded)
        {
            if (roundTime > 0 && Time.time - lastTimeUpdate > 1)
            {
                roundTime--;
                lastTimeUpdate = Time.time;
                if (roundTime == 0)
                {
                    expireTime();
                }
            }

            if (player1.healthPercent <= 0)
            {
                banner.showYouLose();
                battleEnded = true;
            }
            else if (player2.healthPercent <= 0)
            {
                banner.showYouWin();
                battleEnded = true;
            }
        }

        /*if (battleEnded){
         *      Application.LoadLevel("StartScene");
         * }*/
    }