Advertisement
Caminhoneiro

Timer logic

Oct 30th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1.     //Timer logic
  2.     float seconds = 60f;
  3.     int minutes = 2;
  4.     bool startCountDownTimer = false;
  5.     bool battleEnd = false;
  6.     void RoundOneTimerCountdown()
  7.     {
  8.         seconds -=  Time.deltaTime;
  9.         battleCounter.text = minutes.ToString() + " : " + Mathf.Round(seconds).ToString();
  10.         if (seconds <= 1)
  11.         {
  12.             if(seconds <= 1 && minutes == 2)
  13.             {
  14.                 seconds = 59;
  15.                 minutes = 1;
  16.             }
  17.             if(minutes == 1 && seconds <= 1)
  18.             {
  19.                 seconds = 59;
  20.                 minutes = 0;
  21.             }
  22.             if (minutes == 0 && seconds <= 0)
  23.             {
  24.                 seconds = 00;
  25.                 minutes = 0;
  26.                 if(!battleEnd)
  27.                 {
  28.                     GameObject.Find("NetworkManager").GetComponent<GameNetworkManager>().EndBattleByTimer();
  29.                     battleEnd = true;
  30.                 }
  31.             }
  32.         }
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement