Пример #1
0
 public void ProcessEvent(GameEventType eventType, GameEvent <object> gameEvent)
 {
     if (eventType == GameEventType.GameStateEvent)
     {
         switch (gameEvent.Message)
         {
         case "CHANGE_STATE":
             var state = StateTransformer.TransformStringToState(gameEvent.Parameter1);
             SwitchState(state);
             break;
         }
     }
     else if (eventType == GameEventType.InputEvent)
     {
         ActiveState.HandleKeyEvent(gameEvent.Message, gameEvent.Parameter1);
     }
     else if (eventType == GameEventType.TimedEvent)
     {
         if (ActiveState == GameRunning.GetInstance())
         {
             GameRunning.GetInstance().HandleTimedEvent(gameEvent.Message,
                                                        gameEvent.Parameter1, gameEvent.Parameter2);
         }
     }
 }
Пример #2
0
        public void RenderState()
        {
            GameRunning.GetInstance().RenderState();

            foreach (Text but in menuButtons)
            {
                but.RenderText();
            }
        }
Пример #3
0
        public void SwitchState(GameStateType stateType)
        {
            switch (stateType)
            {
            case GameStateType.GameRunning:
                ActiveState = GameRunning.GetInstance();
                break;

            case GameStateType.MainMenu:
                ActiveState = MainMenu.GetInstance();
                break;

            case GameStateType.SelectLevel:
                ActiveState = SelectLevel.GetInstance();
                break;

            case GameStateType.GamePaused:
                ActiveState = GamePaused.GetInstance();
                break;
            }
        }
Пример #4
0
 public static GameRunning GetInstance()
 {
     return(instance ?? (instance = new GameRunning()));
 }
Пример #5
0
 public static void Restart()
 {
     instance = new GameRunning();
 }