Exemple #1
0
 void Start()
 {
     if (CurrentFightStats.GetTimer() > 0)
     {
         //timer = 100;
         timer        = CurrentFightStats.GetTimer();
         counter.text = timer.ToString();
     }
     else
     {
         timer            = -1;
         counter.fontSize = 100;
         counter.text     = "\u221E"; //Infinity symbol
     }
 }
    void Update()
    {
        if (!fightStarted)
        {
            AnnounceFight();
        }
        if (fightStarted)
        {
            StartCoroutine(SwapCharacterWhenDead(player1));
            StartCoroutine(SwapCharacterWhenDead(player2));
            //Declares a winner if all healthBars has been depleted
            if (CheckLifeBars(player1) && !fightEnded)
            {
                SetWinner(player2);
            }
            if (CheckLifeBars(player2) && !fightEnded)
            {
                SetWinner(player1);
            }

            //Prompts the restart fight screen and stops the timer
            if (fightEnded && !restartPrompt)
            {
                if (CurrentFightStats.GetTimer() > 0)
                {
                    timerCounter.GetComponent <Timer>().StopTimer();
                }
                StartCoroutine(PopUpRestartFight());
            }

            //Counts down the time
            if (timerCounter.GetComponent <Timer>().GetTimer() > 0 && !fightEnded)
            {
                timerCounter.GetComponent <Timer>().DecreaseTimer();
            }
            if (timerCounter.GetComponent <Timer>().GetTimer() == 0 && !fightEnded)
            {
                fightEnded = true;
                TimeUpVictory();
            }
        }
    }