32 lines
721 B
C#
32 lines
721 B
C#
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace PashaBibko.PenguinChase.GameState
|
|
{
|
|
public enum GameState
|
|
{
|
|
Lobby,
|
|
Playing,
|
|
}
|
|
|
|
public class GameStateController : NetworkBehaviour
|
|
{
|
|
private static GameStateController sInstance;
|
|
|
|
[SerializeField] private NetworkVariable<GameState> GlobalState = new();
|
|
|
|
private void Awake()
|
|
{
|
|
// Stops overlapping instances
|
|
if (sInstance is not null)
|
|
{
|
|
Debug.LogError($"Multiple of [{nameof(GameStateController)}] cannot exist.");
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
sInstance = this;
|
|
}
|
|
}
|
|
}
|