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