Example #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 !);
        }
Example #2
0
 public GameState(Game game, GamePlayUi ui)
 {
     _game = game;
     _ui   = ui;
     _ui.DropBombCallback = DropBomb;
     _ui.ExitCallback     = OnExit;
     _ui.ToSetupCallback  = ToSetup;
 }