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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameStateController.cs.meta
Normal file
11
Assets/Scripts/GameStateController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7e7ce52c18c2de49bf808434eae1de7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user