This repository has been archived on 2025-03-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mojo-kitchen-chaos/Assets/Scripts/UI/GameStartCountdownUI.cs

45 lines
895 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class GameStartCountdownUI : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI countdownText;
private void Start()
{
GameStateManager.Instace.OnStateChanged += GameStateManager_OnStateChanged;
Hide();
}
private void GameStateManager_OnStateChanged(object sender, System.EventArgs e)
{
if (GameStateManager.Instace.IsCountdownToStartActive())
{
Show();
} else
{
Hide();
}
}
private void Update()
{
countdownText.text = Mathf.Ceil(GameStateManager.Instace.GetCountdownToStartTimer()).ToString();
}
private void Show()
{
gameObject.SetActive(true);
}
private void Hide()
{
gameObject.SetActive(false);
}
}