Ejemplo n.º 1
0
        public void PushState(GameState state)
        {
            BaseState?newState = null;

            switch (state)
            {
            case GameState.Menu:
                _menuUi =
                    new ConsoleBattleshipsUi.ConsoleMenu(MinBoardWidth, MinBoardHeight, MaxBoardWidth, MaxBoardHeight, LoadDbSessions);
                newState = new MenuState(this, _menuUi);
                break;

            case GameState.Setup:
                _setupUi = new ConsoleSetupView();
                newState = new SetupState(this, _setupUi);
                break;

            case GameState.Game:
                _playUi  = new ConsolePlayView();
                newState = new Battleships.GameState(this, _playUi);
                break;
            }

            GameStates.Push(newState !);
        }
Ejemplo n.º 2
0
 public MenuState(Game game, GameMenuUi menuUi)
 {
     _game   = game;
     _menuUi = menuUi;
     _menuUi.StartGameCallback = StartGame;
     _menuUi.SaveCallback      = SaveGame;
     _menuUi.LoadGameCallback  = LoadGame;
     _menuUi.ExitCallback      = Exit;
 }