using System; using UnityEngine; using UnityEngine.UI; using Script.Gameplay.Global; using TMPro; namespace UI { public class GameCountDownViewer : MonoBehaviour { public TMP_Text countdownText; private GameCountdownManager _countdownManager; private void Start() { _countdownManager = GameCountdownManager.Instance; if (_countdownManager != null) { _countdownManager.OnTick.AddListener(UpdateCountdown); } } public void UpdateCountdown(float secondsLeft) { if (countdownText != null) { int seconds = Mathf.CeilToInt(secondsLeft); countdownText.text = "倒计时: " + seconds.ToString(); } } private void OnDestroy() { if (_countdownManager != null) { _countdownManager.OnTick.RemoveListener(UpdateCountdown); } } } }