public void RevealShroud(Point point) { if (!ShroudActive) { return; } // start simple, reveal in all directions var minX = GetSafeXValue(point.X - ShroudRevealDistance); var minY = GetSafeYValue(point.Y - ShroudRevealDistance); var maxX = GetSafeXValue(point.X + ShroudRevealDistance); var maxY = GetSafeYValue(point.Y + ShroudRevealDistance); for (var x = minX; x <= maxX; x++) { for (var y = minY; y <= maxY; y++) { var p = new Point(x, y); if (!ShroudRevealedPoints.Contains(p)) { ShroudRevealedPoints.Add(p); } } } }
public PointDetail GetPoint(int x, int y) { if (x < MinX) { throw new Exception($"Cannot get point where {nameof(x)} is less than {nameof(MinX)} {MinX}"); } if (y < MinY) { throw new Exception($"Cannot get point where {nameof(y)} is less than {nameof(MinY)} {MinY}"); } if (x > MaxX) { throw new Exception($"Cannot get point where {nameof(x)} is greater than {nameof(MaxX)} {MaxX}"); } if (y > MaxY) { throw new Exception($"Cannot get point where {nameof(y)} is greater than {nameof(MaxY)} {MaxY}"); } var point = new PointDetail(x, y); // find all the path intersections foreach (var path in Paths) { var intersect = point.GetPathIntersect(path); if (intersect != null) { point.AddPathIntersect(intersect); } } // find all background intersections point.AddBackgroundItem(BackgroundItems.Where(i => i.TopLeftX <= x && (i.TopLeftX + i.Width - 1) >= x && i.TopLeftY <= y && (i.TopLeftY + i.Height - 1) >= y)); // find all points of interest point.AddPointOfInterest(PointOfInterests.Where(i => i.X == x && i.Y == y)); // is this point shrouded? point.IsShrouded = ShroudActive && !ShroudRevealedPoints.Contains(point); return(point); }