示例#1
0
    private void DetermineNodeValues(Cell currentNode, Cell testingNode)
    {
        if(testingNode == null)
            return;
        if(testingNode == targetNode)
        {
        //			Debug.Log("I Can Seee youuu");
            targetNode.Parent = currentNode;
            foundTarget = true;
            return;
        }

         if (testingNode.myType != startNode.myType)
        {
            return;
        }

        if(!containsCell(closedList, testingNode))
        {
            if(containsCell(openList, testingNode))
            {
                int newGCost = currentNode.g_moveValue + baseMovementCost;

                //If the G cost is better then change the nodes parent and update its costs.
                if (newGCost < testingNode.g_moveValue)
                {
                    testingNode.Parent = currentNode;
                    testingNode.g_moveValue = newGCost;
                    testingNode.CalculateFValue();
                }
            }
            else
            {
                testingNode.Parent = currentNode;
                testingNode.g_moveValue = currentNode.g_moveValue + baseMovementCost;
                testingNode.CalculateFValue();
                AddToOpenList(testingNode);
            }
        }
    }