SnowMan/AStarSearch.cs
/// <summary>
/// Finds the best adjacent Node.
/// </summary>
/// <returns>The new position(x, y) of the best node to approach.</returns>
Finds the best adjacent Node.
Finds the best adjacent Node .
public int[] FindClosest(Node enemy, Node player)
        {
            this.start = enemy;
            this.end = player;
			SetGrid();
            Node tempNode = grid[enemy.PosY, enemy.PosX];
            int dist = tempNode.CostDistFromStartNode;
            AddIntoOpenList(tempNode, dist);
            while (openList.Count() > 0)
            {
                tempNode = PopSmallestTotalDist();
				dist = tempNode.CostDistFromStartNode;
                AddIntoClosedList(tempNode);
                if (tempNode.ID == player.ID) break;
                AddAdjacentNonExploredNodes(tempNode, dist);
            }
            while(tempNode.Parent.ID != enemy.ID)
            {
                tempNode = tempNode.Parent;
            }
            openList.Clear();
            closedList.Clear();
            return new int[] {tempNode.PosX, tempNode.PosY};
        }
public int [ ] FindClosest ( Node enemy , Node player ) { this . start = enemy ; this . end = player ; SetGrid ( ) ; Node tempNode = grid [ enemy . PosY , enemy . PosX ] ; int dist = tempNode . CostDistFromStartNode ; AddIntoOpenList ( tempNode , dist ) ; while ( openList . Count ( ) > 0 ) { tempNode = PopSmallestTotalDist ( ) ; dist = tempNode . CostDistFromStartNode ; AddIntoClosedList ( tempNode ) ; if ( tempNode . ID == player . ID ) break ; AddAdjacentNonExploredNodes ( tempNode , dist ) ; } while ( tempNode . Parent . ID != enemy . ID ) { tempNode = tempNode . Parent ; } openList . Clear ( ) ; closedList . Clear ( ) ; return new int [ ] { tempNode . PosX , tempNode . PosY } ; }
Finds the best adjacent Node.
Finds the best adjacent Node .
The new position(x, y) of the best node to approach.
The new position ( x y ) of the best node to approach .
enemy
Node
player
Node