Ejemplo n.º 1
0
        static bool IsPointWallsExceptSource(IMapView <bool> map, Coord location, Direction sourceDirection)
        {
            // exclude the outside of the map
            var mapInner = map.Bounds().Expand(-1, -1);

            if (!mapInner.Contains(location))
            {
                // Shortcut out if this location is part of the map edge.
                //if (IsPointMapEdge(location) || IsPointPartOfRegion(location, true))
                return(false);
            }

            // Get map indexes for all surrounding locations
            var index = AdjacencyRule.EIGHT_WAY.DirectionsOfNeighborsClockwise().ToArray();

            Direction[] skipped;

            if (sourceDirection == Direction.RIGHT)
            {
                skipped = new[] { sourceDirection, Direction.UP_RIGHT, Direction.DOWN_RIGHT }
            }
            ;
            else if (sourceDirection == Direction.LEFT)
            {
                skipped = new[] { sourceDirection, Direction.UP_LEFT, Direction.DOWN_LEFT }
            }
            ;
            else if (sourceDirection == Direction.UP)
            {
                skipped = new[] { sourceDirection, Direction.UP_RIGHT, Direction.UP_LEFT }
            }
            ;
            else
            {
                skipped = new[] { sourceDirection, Direction.DOWN_RIGHT, Direction.DOWN_LEFT }
            };

            for (int i = 0; i < index.Length; i++)
            {
                if (skipped[0] == index[i] || skipped[1] == index[i] || skipped[2] == index[i])
                {
                    continue;
                }

                //if (index[i] == -1)
                //    return false;

                if (!map.Bounds().Contains(location + index[i]) || map[location + index[i]])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        static bool IsPointSurroundedByWall(IMapView <bool> map, Coord location)
        {
            var points = AdjacencyRule.EIGHT_WAY.Neighbors(location);

            var mapBounds = map.Bounds();

            foreach (var point in points)
            {
                if (!mapBounds.Contains(point))
                {
                    return(false);
                }

                if (map[point])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor. Takes the MapView to represent. Initial ViewArea will be the entire MapView.
 /// </summary>
 /// <param name="mapView">The MapView to represent.</param>
 public Viewport(IMapView <T> mapView)
     : this(mapView, mapView.Bounds())
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor. Takes the MapView to represent, and the initial ViewArea for that map.
 /// </summary>
 /// <param name="mapView">The map view being represented.</param>
 /// <param name="viewArea">The initial ViewArea for that map.</param>
 public Viewport(IMapView <T> mapView, Rectangle viewArea)
 {
     MapView      = mapView;
     _boundedRect = new BoundedRectangle(viewArea, MapView.Bounds());
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor. Takes the MapView to represent. Initial ViewArea will be the entire MapView.
 /// </summary>
 /// <param name="mapView">The MapView to represent.</param>
 /// <param name="defaultValue">The value to return if a position is accessed that is outside the actual underlying map view.</param>
 public UnboundedViewport(IMapView <T> mapView, T defaultValue = default(T))
     : this(mapView, mapView.Bounds(), defaultValue)
 {
 }