private void AddShips(Board board) { var shipFactory = new ShipFactory(); foreach (var shipType in this._shipsType) { for (var i = 0; i < shipType.Value; i++) { var direction = this.GetRandomShipDirection(); var ship = shipFactory.Get(shipType.Key.Name, direction); ship.OriginPosition = this.GetRandomShipPosition(direction, ship.Length, board.Width, board.Height); while (board.ShipsOverlap(ship)) { ship.OriginPosition = this.GetRandomShipPosition(direction, ship.Length, board.Width, board.Height); } board.PlaceShip(ship); } } }
void CreatePlayer() { player = enemyFactory.Get(ShipType.Player); player.transform.position = new Vector3(0, -4, 0); }