Esempio n. 1
0
        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);
        }