using UnityEngine;
///
/// singleton for a single source of truth game state and flow management
///
public class GameManager : MonoBehaviour
{
///
/// enum for available menus in the game, for use with ShowMenu()
///
public enum DisplayState
{
ScreenStart,
OverlayAccountManagement,
OverlaySettings,
OverlayLeaderboard,
Game,
UnassociatedState
}
///
/// singleton pattern: define instance field for accessing the singleton elsewhere
///
public static GameManager Instance;
///
/// enforces singleton behaviour; sets doesn't destroy on load and checks for multiple instances
///
private void Awake()
{
// check if instance hasn't been set yet
if (Instance == null)
{
Debug.Log("awake as singleton instance, setting self as the forever-alive instance");
Instance = this;
DontDestroyOnLoad(gameObject);
}
// check if instance is already set and it's not this instance
else if (Instance != null && Instance != this)
{
Debug.Log("awake as non-singleton instance, destroying self");
Destroy(gameObject);
}
}
}