This commit is contained in:
Yorick
2015-04-08 14:46:08 +02:00
parent a6eb4578da
commit f571189849
2 changed files with 29 additions and 14 deletions
+14 -2
View File
@@ -73,7 +73,7 @@ public class Panel extends JPanel implements ActionListener
Point lastMousePosition = new Point(0, 0);
Point2D selectionPosition = new Point(0, 0);
Images images = new Images();
javax.swing.Timer t;
Timer t;
SimpleDateFormat formatter;
GregorianCalendar date;
@@ -211,6 +211,18 @@ public class Panel extends JPanel implements ActionListener
{
waypoints.add(w);
}
public Waypoint getWaypoint(int i)
{
for(Waypoint w : waypoints)
{
if(w.getSelf() == i)
{
return w;
}
}
return null;
}
public ArrayList<Waypoint> getWaypoints()
{
@@ -231,7 +243,7 @@ public class Panel extends JPanel implements ActionListener
visitors.add(new Visitor("visitor",point, agenda, objects));
}
else {
JOptionPane.showMessageDialog(this, "You don't have a entrance");
JOptionPane.showMessageDialog(this, "You don't have an entrance");
}
}
+15 -12
View File
@@ -28,6 +28,7 @@ public class Visitor
Agenda agenda;
ArrayList<DrawObject> objects;
int target;
int finalTarget;
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
{
@@ -42,6 +43,7 @@ public class Visitor
fillActions();
System.out.println(actions.size());
target = 0;
finalTarget = 0;
}
public void draw(Graphics2D g2)
@@ -88,6 +90,11 @@ public class Visitor
moveToTarget(target, objects, visitors, paths);
}
public void move(DrawObject tar)
{
}
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
{
Point2D tar = target.getPosition();
@@ -217,18 +224,14 @@ public class Visitor
int dify = (int) (target2.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
System.out.println(rotation);
System.out.println(newRot);
System.out.println("--------------");
// if (rotation > newRot && distance > 10)
// {
// rotation -= 0.15;
// }
// else if (rotation < newRot && distance > 10)
// {
// rotation += 0.15;
// }
rotation = newRot;
if (rotation > newRot && distance > 10)
{
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
rotation += 0.15;
}
Point2D oldPosition = position;