Example #1
0
 static void AnalyzeNode()
 {
     if (!GridHeap.Contains(neighbor))
     {
         AddBestNode();
         GridHeap.Add(neighbor);
     }
     else if (newMovementCostToNeighbor < neighbor.gCost)
     {
         AddBestNode();
         GridHeap.UpdateItem(neighbor);
     }
 }
Example #2
0
        static void AnalyzeNode()
        {
            if (!GridHeap.Contains(neighbor))
            {
                neighbor.gCost = newMovementCostToNeighbor;

                //Optimized heuristic calculation
                neighbor.CalculateHeuristic();
                neighbor.parent = currentNode;

                GridHeap.Add(neighbor);
            }
            else if (newMovementCostToNeighbor < neighbor.gCost)
            {
                neighbor.gCost = newMovementCostToNeighbor;

                //Optimized heuristic calculation
                neighbor.CalculateHeuristic();
                neighbor.parent = currentNode;

                GridHeap.UpdateItem(neighbor);
            }
        }