Ejemplo n.º 1
0
        /// <summary>
        /// Gets the distance between two points
        /// </summary>
        internal static float GetTraversalCost(Point location, Point otherLocation)
        {
            float deltaX = otherLocation.X - location.X;
            float deltaY = otherLocation.Y - location.Y;

            return((float)Math.Sqrt(deltaX * deltaX + deltaY * deltaY));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of Node.
 /// </summary>
 /// <param name="x">The node's location along the X axis</param>
 /// <param name="y">The node's location along the Y axis</param>
 /// <param name="isWalkable">True if the node can be traversed, false if the node is a wall</param>
 /// <param name="endLocation">The location of the destination node</param>
 public Node(int x, int y, bool isWalkable, Point endLocation)
 {
     this.Location   = new Point(x, y);
     this.State      = NodeState.Untested;
     this.IsWalkable = isWalkable;
     this.H          = GetTraversalCost(this.Location, endLocation);
     this.G          = 0;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the eight locations immediately adjacent (orthogonally and diagonally) to <paramref name="fromLocation"/>
        /// </summary>
        /// <param name="fromLocation">The location from which to return all adjacent points</param>
        /// <returns>The locations as an IEnumerable of Points</returns>
        private static IEnumerable <Point> GetAdjacentLocations(Point fromLocation)
        {
            return(new Point[]
            {
//				new Point(fromLocation.X-1, fromLocation.Y-1),
                new Point(fromLocation.X - 1, fromLocation.Y),
//				new Point(fromLocation.X-1, fromLocation.Y+1),
                new Point(fromLocation.X, fromLocation.Y + 1),
//				new Point(fromLocation.X+1, fromLocation.Y+1),
                new Point(fromLocation.X + 1, fromLocation.Y),
//				new Point(fromLocation.X+1, fromLocation.Y-1),
                new Point(fromLocation.X, fromLocation.Y - 1)
            });
        }
Ejemplo n.º 4
0
 public SearchParameters(Point startLocation, Point endLocation, bool[,] map)
 {
     this.StartLocation = startLocation;
     this.EndLocation   = endLocation;
     this.Map           = map;
 }