37 lines
986 B
C#
37 lines
986 B
C#
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|