Add basic intro countdown and game states
This commit is contained in:
parent
89e482d387
commit
15abaa80fa
10 changed files with 740 additions and 6 deletions
45
Assets/Scripts/UI/GameStartCountdownUI.cs
Normal file
45
Assets/Scripts/UI/GameStartCountdownUI.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
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);
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/GameStartCountdownUI.cs.meta
Normal file
11
Assets/Scripts/UI/GameStartCountdownUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e210821ea09ba64fa474a98e4760bcb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue