Example #1
0
 public AStarSearch(int rows, int cols)
 {
     Rows = rows;
     Cols = cols;
     Nodes = new AStarNode[Rows,Cols];
     for (int r = 0; r < Rows; r++)
     {
         for (int c = 0; c < Cols; c++)
         {
             Nodes[r, c] = new AStarNode();
         }
     }
 }
Example #2
0
 public void AddToOpenList(AStarNode node, AStarNode current, AStarNode end)
 {
     if (!node.Passable)
     {
         return;
     }
     node.Heuristic = Vector3.Distance(node.Position, end.Position);
     node.Cost = (current != null) ? current.Cost + 1 : 0;
     node.Parent = current;
     node.Closed = true;
     if (!OpenList.ContainsKey(node.Cost + node.Heuristic))
     {
         OpenList[node.Cost + node.Heuristic] = new List<AStarNode>();
     }
     OpenList[node.Cost + node.Heuristic].Add(node);
 }