2025-10-18 10:06:12 +08:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using Script.Gameplay.Global;
|
2025-10-19 19:38:52 +08:00
|
|
|
using TMPro;
|
|
|
|
|
2025-10-18 10:06:12 +08:00
|
|
|
namespace UI
|
|
|
|
{
|
|
|
|
public class GameCountDownViewer : MonoBehaviour
|
|
|
|
{
|
2025-10-19 19:38:52 +08:00
|
|
|
public TMP_Text countdownText;
|
2025-10-18 10:06:12 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|