예제 #1
0
        private Coordinates DamagedShipShot()
        {
            Random rand         = new Random(Guid.NewGuid().GetHashCode());
            var    hitNeighbors = EnemyBoard.GetHitNeighbors();
            var    neighborID   = rand.Next(hitNeighbors.Count);

            return(hitNeighbors[neighborID]);
        }
예제 #2
0
        private Coordinates RandomShot()
        {
            var    availableFields = EnemyBoard.GetOpenRandomFields();
            Random rand            = new Random(Guid.NewGuid().GetHashCode());
            var    fieldID         = rand.Next(availableFields.Count);

            return(availableFields[fieldID]);
        }
예제 #3
0
 public Player(string name)
 {
     Name  = name;
     Ships = new List <Ship>()
     {
         new Destroyer(),
         new Destroyer(),
         new Battleship(),
     };
     GameBoard  = new Board();
     EnemyBoard = new EnemyBoard();
 }
예제 #4
0
        public Coordinates FireShot()
        {
            var         hitNeighbors = EnemyBoard.GetHitNeighbors();
            Coordinates coords;

            if (hitNeighbors.Any())
            {
                coords = DamagedShipShot();
            }
            else
            {
                coords = RandomShot();
            }
            return(coords);
        }