Timer.cs 557 B

1234567891011121314151617181920212223
  1. using TMPro;
  2. using UnityEngine;
  3. public class Timer : MonoBehaviour
  4. {
  5. [SerializeField] float timerTime = 60.00f;
  6. [SerializeField] TextMeshProUGUI timerText;
  7. private void Update()
  8. {
  9. if(GameManager.gameManagerInstance.gameState == GameManager.GameState.Playing)
  10. {
  11. timerTime -= Time.deltaTime;
  12. timerText.text = timerTime.ToString();
  13. if(timerTime < 0)
  14. {
  15. GameManager.gameManagerInstance.gameState = GameManager.GameState.GameOver;
  16. }
  17. }
  18. }
  19. }