예제 #1
0
        private HashSet <Point> GetShipRoundPoints(IShip ship)
        {
            var result = ship.GetPositionPoints()
                         .SelectMany(p => p.GetRoundPoints())
                         .Where(p => 0 <= p.X && p.X < Width && 0 <= p.Y && p.Y < Height)
                         .ToHashSet();

            return(result);
        }
예제 #2
0
        public bool IsAlive(IShip ship)
        {
            if (!ships.Contains(ship))
            {
                throw new InvalidOperationException();
            }

            return(ship.GetPositionPoints().Any(p => !shots.Contains(p)));
        }
예제 #3
0
 private void PaintShip(Graphics graphics, IShip ship,
                        ISet <Domain.Point> conflictingPoints, ISet <Domain.Point> shots, bool useLight)
 {
     foreach (var point in ship.GetPositionPoints())
     {
         if (!fogOfWar || shots.Contains(point))
         {
             graphics.DrawShipCell(pointToRectangle[point],
                                   useLight: useLight,
                                   inConflict: conflictingPoints.Contains(point),
                                   isShot: shots.Contains(point));
         }
     }
 }