protected override void AddShips() { _numbOfCurrentAddingShip = 0; for (; _numbOfCurrentAddingShip < _shipSize.Length; ++_numbOfCurrentAddingShip) { _sizeOfCurrentAddingShip = _shipSize[_numbOfCurrentAddingShip]; bool wantAdd; _coordYAddingShip = (_coordYAddingShip + _sizeOfCurrentAddingShip > BoardSize.Width) ? BoardSize.LeftEdge : _coordYAddingShip; do { _isFitAddingShip = true; PrepareToAdd(); if (!_isFitAddingShip) { _outputDevice.SetBottomMessage(0); } Player leftPlayer = WhichBoard == BoardSide.Left ? this : Opponent; Player rightPlayer = WhichBoard == BoardSide.Right ? this : Opponent; _outputDevice.PrintBoard(leftPlayer.Board, rightPlayer.Board, true); _outputDevice.SetBottomMessage(-1); wantAdd = WantAdd(); _sizeOfCurrentAddingShip = _shipSize[_numbOfCurrentAddingShip]; IsInBoard(); } while (!wantAdd || !_isFitAddingShip); CreateShip(); } Board.ClearNearShipMarks(); }
protected override void AddShips() { int shipNumb = 0; foreach (int currSize in _shipSize) { PlayerShips[shipNumb] = MakeShip(currSize, shipNumb); DrawShip(shipNumb); MarkShipNeighborhood(false, shipNumb); ++shipNumb; } Board.ClearNearShipMarks(); }
private void AddShipsTest() { for (int i = 0; i < 5; i++) { PlayerShips[i] = new Ship(2 * i, 0, 5, i, false); DrawShip(i); MarkShipNeighborhood(false, i); } for (int i = 5; i < 10; i++) { PlayerShips[i] = new Ship(2 * (i - 5), 6, 4, i, false); DrawShip(i); MarkShipNeighborhood(false, i); } Board.ClearNearShipMarks(); }