Добавил отображение таймера

This commit is contained in:
2026-06-06 15:31:50 +03:00
parent d0abca743e
commit b224dc1648
3 changed files with 60 additions and 0 deletions
+39
View File
@@ -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";
}
}