Added cash counter
This commit is contained in:
@@ -9,32 +9,38 @@ namespace Fruitomation
|
||||
Building,
|
||||
UpgradeMenu,
|
||||
Paused,
|
||||
None
|
||||
Default
|
||||
}
|
||||
|
||||
[CreateInstanceOnStart] public class GameStateController : MonoBehaviour
|
||||
{
|
||||
private static GameStateController Instance;
|
||||
|
||||
private GameState InternalState = GameState.None;
|
||||
[SerializeField, InspectorReadOnly("Game State")] private GameState InternalState;
|
||||
public static GameState State
|
||||
{
|
||||
get => Instance.InternalState;
|
||||
set
|
||||
{
|
||||
Debug.Log($"Changing state from [{Instance.InternalState}] to [{value}]");
|
||||
Instance.InternalState = value;
|
||||
if (Instance.InternalState != value)
|
||||
{
|
||||
Debug.Log($"Changing state from [{Instance.InternalState}] to [{value}]");
|
||||
Instance.InternalState = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Is(GameState state) => State == state;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance is not null)
|
||||
{
|
||||
Debug.LogError($"Cannot have multiple instances of [GameStateController]");
|
||||
Debug.LogError("Cannot have multiple instances of [GameStateController]");
|
||||
return;
|
||||
}
|
||||
|
||||
InternalState = GameState.Default;
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user