Created
January 30, 2015 18:38
-
-
Save ellisonleao/1040b2273a4f86edb44c to your computer and use it in GitHub Desktop.
SimpleGameManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
// Game States | |
public enum GameState { INTRO, MAIN_MENU, PAUSED, GAME, CREDITS, HELP } | |
public delegate void OnStateChangeHandler(); | |
public class SimpleGameManager: Object { | |
protected SimpleGameManager() {} | |
private static SimpleGameManager instance = null; | |
public event OnStateChangeHandler OnStateChange; | |
public GameState gameState { get; private set; } | |
public static SimpleGameManager Instance{ | |
get { | |
if (SimpleGameManager.instance == null){ | |
SimpleGameManager.instance = new SimpleGameManager(); | |
DontDestroyOnLoad(SimpleGameManager.instance); | |
} | |
return SimpleGameManager.instance; | |
} | |
} | |
public void SetGameState(GameState state){ | |
this.gameState = state; | |
OnStateChange(); | |
} | |
public void OnApplicationQuit(){ | |
SimpleGameManager.instance = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment