SHARE
TWEET

Untitled

a guest Nov 2nd, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private IndexedAStarPathFinder<Node> pathFinder = new IndexedAStarPathFinder<Node>(MapManager.graph, false);
  2. private GraphPath<Node> resultPath;
  3. private int startX, startY, endX, endY;
  4. private Node startNode, endNode;
  5. private PathFinderRequest<Node> request = new PathFinderRequest<Node>(startNode, endNode, heuristic, resultPath);
  6.  
  7.  
  8. public void initPath(){
  9.         startX = (int) (aiSteering.getPosition().x);
  10.         startY = (int) (aiSteering.getPosition().y);
  11.        
  12.         endX = (int) (aiSteering.getTarget().getPosition().x);
  13.         endY = (int) (aiSteering.getTarget().getPosition().y);
  14.  
  15.         startNode = MapManager.graph.getNodeByXY(startX, startY);
  16.         endNode = MapManager.graph.getNodeByXY(endX, endY);
  17.        
  18.         waypoint.setTarget(aiSteering.getTarget());
  19.        
  20.         request.startNode = startNode;
  21.         request.endNode = endNode;
  22.         request.heuristic = heuristic;
  23.        
  24.         if(resultPath != null &&resultPath.getCount() > 0)
  25.         {
  26.             resultPath.clear();
  27.         }
  28.         if(request.resultPath != null && request.resultPath.getCount() > 0)
  29.         {
  30.             request.resultPath.clear();
  31.         }
  32.         pathFinder.search(request, 1000000000);
  33.         resultPath = request.resultPath;
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top