Example #1
0
        public Coordinates SearchingShot()   // returns Coordinates the Player wants to fire
        {
            Random random         = new Random(Guid.NewGuid().GetHashCode());
            var    hitNeighbours  = FiringBoard.GetHitNeighbours();
            var    neighbourIndex = random.Next(hitNeighbours.Count);

            return(hitNeighbours[neighbourIndex]);
        }
Example #2
0
        // FIRING
        public virtual Coordinates FireShot()
        {
            var         hitNeighbours = FiringBoard.GetHitNeighbours();
            Coordinates coordinatesToShotAt;

            if (hitNeighbours.Any())
            {
                coordinatesToShotAt = SearchingShot();
            }
            else
            {
                coordinatesToShotAt = RandomShot();
            }

            Console.WriteLine(Name + " says: \"Firing shot at "
                              + coordinatesToShotAt.row.ToString() + ":"
                              + coordinatesToShotAt.column.ToString()
                              + "\"");

            return(coordinatesToShotAt);
        }