Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 public static GamePaused GetInstance()
 {
     return(GamePaused.instance ?? (GamePaused.instance = new GamePaused()));
 }