public bool runASTAR(float targetX, float targetY) { Astar pathFinder = new Astar(); bool pathFound = false; bool targetFound = false; cleanPath(); try { pathFinder.allocNode(Globals.gamedata.my_char.X, Globals.gamedata.my_char.Y, 0, 0); pathFinder.findStartNode(); targetFound = pathFinder.findTargetNode(targetX, targetY); if(targetFound) { pathFound = pathFinder.fringeSearch(); pathFinder.trimPath(); pathFinder.buildPathPoints(); path = pathFinder.pathPoints; #if DEBUG pathFinder.printPath(); #endif pathFinder = null; //send A* object to garbage collector. } else Globals.l2net_home.Add_Error("Could not find target node at " + targetX + "," + targetY); } catch(Exception e) { //eh? Globals.l2net_home.Add_Debug(e.Message); } return (pathFound && targetFound); }
public bool runASTAR(float targetX, float targetY) { Astar pathFinder = new Astar(); bool pathFound = false; bool targetFound = false; cleanPath(); try { pathFinder.allocNode(Globals.gamedata.my_char.X, Globals.gamedata.my_char.Y, 0, 0); pathFinder.findStartNode(); targetFound = pathFinder.findTargetNode(targetX, targetY); if (targetFound) { pathFound = pathFinder.fringeSearch(); pathFinder.trimPath(); pathFinder.buildPathPoints(); path = pathFinder.pathPoints; #if DEBUG pathFinder.printPath(); #endif pathFinder = null; //send A* object to garbage collector. } else { Globals.l2net_home.Add_Error("Could not find target node at " + targetX + "," + targetY); } } catch (Exception e) { //eh? Globals.l2net_home.Add_Debug(e.Message); } return(pathFound && targetFound); }