public StateMachine() { GalagaBus.GetBus().Subscribe(GameEventType.GameStateEvent, this); GalagaBus.GetBus().Subscribe(GameEventType.InputEvent, this); gameRunning = GameRunning.GetInstance(); gameRunning.InitializeGameState(); gamePaused = GamePaused.GetInstance(); gamePaused.InitializeGameState(); mainMenu = MainMenu.GetInstance(); mainMenu.InitializeGameState(); ActiveState = mainMenu; }
private void SwitchState(GameStateType stateType) { switch (stateType) { case GameStateType.MainMenu: ActiveState = MainMenu.GetInstance(); break; case GameStateType.GamePaused: ActiveState = GamePaused.GetInstance(); break; case GameStateType.GameRunning: ActiveState = GameRunning.GetInstance(); break; } }
public static GamePaused GetInstance() { return(GamePaused.instance ?? (GamePaused.instance = new GamePaused())); }