コード例 #1
0
ファイル: GameController.cs プロジェクト: DDFaller/Battleship
        public void NewGame()
        {
            _gameUI.Clear();

            _gameOver = false;

            Players = new List <Player>();

            var placements   = GetStrategies <IPlacementStrategy>();
            var bombardments = GetStrategies <IBombardmentStrategy>();

            for (int i = 0; i < 2; i++)
            {
                _gameUI.AddBoard();
                _gameUI.PlayerBoards[i].SetDropdownOptions(placements, bombardments);

                Players.Add(new Player(_gridSize)
                {
                    Name  = string.Format("Player {0}", i + 1),
                    ID    = i,
                    Ships = new List <IShip>()
                    {
                        new ShipCarrier(),
                        new ShipBattleship(),
                        new ShipBattleship(),
                        new ShipCruiser(),
                        new ShipCruiser(),
                        new ShipCruiser(),
                        new ShipDestroyer(),
                        new ShipDestroyer(),
                        new ShipDestroyer(),
                        new ShipDestroyer(),
                    },
                });
            }
        }