boolean routeFound = false;
PriorityQueue openlist = new PriorityQueue();
Vector<Waypoint> closedlist = new Vector<Waypoint>();
Waypoint wp_to = new Waypoint(mc_to,0);
Waypoint currentWP;
Vector<Waypoint> newWaypoints;
//System.err.println("Fuege Punkt to zu openlist hinzu: " + to.toString());
openlist.insert(wp_to, 0);
do{
//System.err.println(openlist.toString());
currentWP = openlist.getFirst();
//System.err.println("Hole Node von der openlist: " + currentWP.toString());
//if (currentWP.getVector2f().equals(from))
if (currentWP.getVector2f().isInRange(mc_from, 0.707f))
{
System.out.println("Weg gefunden!!");
routeFound = true;
break;
}
closedlist.add(currentWP);
// Expand Node
Vector2f currentpoint = currentWP.getVector2f();
newWaypoints = new Vector<Waypoint>(8);
//8er Nachbarschaft hinzufuegen
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y()-1 ), Math.sqrt(2) ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y() ), 1 ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y()+1 ), Math.sqrt(2) ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x() , currentpoint.y()-1 ), 1 ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x() , currentpoint.y()+1 ), 1 ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y()-1 ), Math.sqrt(2) ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y() ), 1 ,currentWP));
newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y()+1 ), Math.sqrt(2) ,currentWP));
//System.err.println("Alle punkte zum vektor hinzugefuegt");
for(Waypoint wp : newWaypoints)
{
if ( (closedlist.contains(wp)) || (!map.isInMap(wp.getVector2f())) || (!map.isPassable(vehicletype, wp.getVector2f())) )
{
continue;
}
double estimatedDistance = wp.getDistance()+wp.getVector2f().getDistanceTo(mc_from);
openlist.insert(wp, estimatedDistance);
}
}
while (!openlist.isEmpty());
if (routeFound)
{
Vector<Vector2f> mc_wps = new Vector<Vector2f>();
Vector<Vector2f> wc_waypoints = new Vector<Vector2f>();
currentWP.getRouteList(mc_wps);
for(Vector2f wp:mc_wps)
{
wc_waypoints.add(general.helperclasses.Math.mapToWorld(wp, map.getTilesize()));
}
wc_waypoints.remove(0);