mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Добавил отображение таймера
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TimerViewer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TurretsBuildTimer _timer;
|
||||
[SerializeField] private GameManager _gameManager;
|
||||
[SerializeField] private TMPro.TextMeshProUGUI _btnText;
|
||||
|
||||
private bool _isFirstTime = true;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_timer.OnTick += OnTick;
|
||||
_gameManager.OnLevelChanged += OnLevelStart;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_timer.OnTick -= OnTick;
|
||||
_gameManager.OnLevelChanged -= OnLevelStart;
|
||||
}
|
||||
|
||||
private void OnTick(TurretsBuildTimer.OnTickEventArgs args)
|
||||
{
|
||||
if (_isFirstTime)
|
||||
{
|
||||
_btnText.text = $"Start ({args.SecondsLeft:0})";
|
||||
return;
|
||||
}
|
||||
|
||||
_btnText.text = $"Next wave ({args.SecondsLeft:0})";
|
||||
}
|
||||
|
||||
private void OnLevelStart(GameManager.OnLevelChangedEventArgs _)
|
||||
{
|
||||
_isFirstTime = false;
|
||||
_btnText.text = "Next wave";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8f51f072b7c7e64b8fde0e36109e334
|
||||
Reference in New Issue
Block a user