using System; using TMPro; using UnityEngine; public class GameStartCountdownUI : MonoBehaviour { private const string NumberPopup = "NumberPopup"; [SerializeField] private TextMeshProUGUI countdownText; private Animator animator; private int previousCountdownNumber; private void Awake() { animator = GetComponent(); } private void Start() { KitchenGameManager.Instance.OnStateChanged += KitchenGameManager_OnStateChanged; Hide(); } private void Update() { int countdownNumber = Mathf.CeilToInt(KitchenGameManager.Instance.CountdownToStartTimer); countdownText.text = countdownNumber.ToString(); if (previousCountdownNumber != countdownNumber) { previousCountdownNumber = countdownNumber; animator.SetTrigger(NumberPopup); SoundManager.Instance.PlayCountdownSound(); } } private void KitchenGameManager_OnStateChanged(object sender, EventArgs e) { if (KitchenGameManager.Instance.IsCountToStartActive()) Show(); else Hide(); } private void Hide() { gameObject.SetActive(false); } private void Show() { gameObject.SetActive(true); } }