using UnityEngine; using UnityEngine.Serialization; public class TimerManager : MonoBehaviour { [SerializeField, FormerlySerializedAs("player1Timer")] private Timer _player1Timer; [SerializeField, FormerlySerializedAs("player2Timer")] private Timer _player2Timer; [SerializeField, FormerlySerializedAs("vsBotTime")] private float _vsBotTime = 180f; [SerializeField, FormerlySerializedAs("pvpTime")] private float _pvpTime = 90f; public void SetupTimers(GameMode gameMode) { if (_player1Timer != null) _player1Timer.SetupTimer(gameMode == GameMode.pve ? _vsBotTime : _pvpTime); if (gameMode == GameMode.pvp && _player2Timer != null) _player2Timer.SetupTimer(_pvpTime); SetTimersActivity(gameMode); } public void SetTimersActivity(GameMode gameMode) { bool activateSecondTimer = gameMode == GameMode.pvp; if (_player1Timer != null) _player1Timer.gameObject.SetActive(true); if (_player2Timer != null) _player2Timer.gameObject.SetActive(activateSecondTimer); } public void StopAllTimers() { _player1Timer?.StopTimer(); _player2Timer?.StopTimer(); } public void SetActiveTimer(Team currentPlayer) { Timer activeTimer = currentPlayer == Team.Player1 ? _player1Timer : _player2Timer; Timer inactiveTimer = currentPlayer == Team.Player1 ? _player2Timer : _player1Timer; activeTimer?.StartTimer(); inactiveTimer?.StopTimer(); } }