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); }
public bool IsAlive(IShip ship) { if (!ships.Contains(ship)) { throw new InvalidOperationException(); } return(ship.GetPositionPoints().Any(p => !shots.Contains(p))); }
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)); } } }