Added GameState controller
This commit is contained in:
41
Assets/Scripts/GameStateController.cs
Normal file
41
Assets/Scripts/GameStateController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation
|
||||
{
|
||||
public enum GameState
|
||||
{
|
||||
Simulation,
|
||||
Building,
|
||||
UpgradeMenu,
|
||||
Paused,
|
||||
None
|
||||
}
|
||||
|
||||
[CreateInstanceOnStart] public class GameStateController : MonoBehaviour
|
||||
{
|
||||
private static GameStateController Instance;
|
||||
|
||||
private GameState InternalState = GameState.None;
|
||||
public static GameState State
|
||||
{
|
||||
get => Instance.InternalState;
|
||||
set
|
||||
{
|
||||
Debug.Log($"Changing state from [{Instance.InternalState}] to [{value}]");
|
||||
Instance.InternalState = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance is not null)
|
||||
{
|
||||
Debug.LogError($"Cannot have multiple instances of [GameStateController]");
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user