feat(TimeCountDown): 实现倒计时功能

This commit is contained in:
2025-10-18 10:06:12 +08:00
parent 48d872b4b9
commit 2614dab342
16 changed files with 687 additions and 70 deletions

View File

@@ -0,0 +1,37 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using Script.Gameplay.Global;
namespace UI
{
public class GameCountDownViewer : MonoBehaviour
{
public 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);
}
}
}
}