示例#1
0
        public Coordinates GetStartingCoordinatesForShip(Ship ship, ShipOrientation orientation)
        {
            int endIndex                    = GetEndIndexForShipRandom(ship, orientation);
            int firstCoordinate             = _randFirstCoordinateOfShip.Next(1, endIndex);
            int endIndexForSecondCoordinate = orientation == ShipOrientation.Vertical ? _board.Columns - 1 : _board.Rows - 1;
            int secondCoordinate            = _randSecondCoordinateOfShip.Next(1, endIndexForSecondCoordinate);
            int x          = orientation == ShipOrientation.Vertical ? firstCoordinate : secondCoordinate;
            int y          = orientation == ShipOrientation.Horizontal ? firstCoordinate : secondCoordinate;
            var coordinate = new ShipCoordinates(x, y);

            return(coordinate);
        }
示例#2
0
 public Ship(int length)
 {
     Id = Guid.NewGuid();
     CoordinatesFields = new ShipCoordinates[length];
 }