/* AIBiDirectionalSearch is a constructor for this class * Parameter: Vector3 goalToAdd - location of the goal * AIPolygon[] polygonArrayToAdd - array holding the polygons that will be used to search */ public AIBiDirectionalSearch(Vector3 goalToAdd, AIPolygon[] polygonArrayToAdd) { polygonArray = polygonArrayToAdd; polygonFinalCount = 0; maxQueueSize = 0; nodesVisited = 0; finalPathCost = 0f; agentToGoal = new AIBiDirectionalAStarAgent(goalToAdd, polygonArray, false); goalToAgent = new AIBiDirectionalAStarAgent(AINavigationMeshAgent.agentStart, polygonArray, true); }
/* The getPathFromBiDirectionAgent gets the path from the AIBiDirectionalAStarAgent and sets * the stats needed for analysis( final polygon count, nodes visited, and maz queue size) * Parameter: AIBiDirectionalAStarAgent agentThatFoundPath - Agent that carried out the search */ void getPathFromBiDirectionAgent(AIBiDirectionalAStarAgent agentThatFoundPath) { finalSolutionArray = agentThatFoundPath.getFinalPath(); polygonFinalCount = agentThatFoundPath.getFinalPathLength(); for (int count = 1; count < finalSolutionArray.Length; count++) { finalPathCost += (finalSolutionArray [count].getCenterVector() - finalSolutionArray [count - 1].getCenterVector()).magnitude; } nodesVisited = agentToGoal.getNodesVisited() + goalToAgent.getNodesVisited(); maxQueueSize = agentToGoal.getMaxQueueSize() + goalToAgent.getMaxQueueSize(); }