Working
This commit is contained in:
+31
-11
@@ -2,7 +2,6 @@ package Applicatie;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
@@ -14,6 +13,7 @@ import java.util.Map;
|
||||
import Agenda.Agenda;
|
||||
import Agenda.Event;
|
||||
import Objects.DrawObject;
|
||||
import Objects.Entrance;
|
||||
import Objects.Path;
|
||||
|
||||
public class Visitor
|
||||
@@ -27,7 +27,7 @@ public class Visitor
|
||||
ArrayList<Action> actions;
|
||||
Agenda agenda;
|
||||
ArrayList<DrawObject> objects;
|
||||
char target;
|
||||
int target;
|
||||
|
||||
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
|
||||
{
|
||||
@@ -40,7 +40,8 @@ public class Visitor
|
||||
this.agenda = agenda;
|
||||
this.objects = objects;
|
||||
fillActions();
|
||||
target = 'z';
|
||||
System.out.println(actions.size());
|
||||
target = 0;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2)
|
||||
@@ -60,24 +61,36 @@ public class Visitor
|
||||
return tx;
|
||||
}
|
||||
|
||||
public DrawObject getEntrance()
|
||||
{
|
||||
for(DrawObject o : objects)
|
||||
{
|
||||
if(o instanceof Entrance)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||
{
|
||||
Point2D target = new Point(500, 500);
|
||||
DrawObject target = getEntrance();
|
||||
for (Action a : actions)
|
||||
{
|
||||
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
|
||||
{
|
||||
target = a.getPosition();
|
||||
target = a.getTargetObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
moveToTarget(target, objects, visitors, paths);
|
||||
}
|
||||
|
||||
public void moveToTarget(Point2D target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||
{
|
||||
Point2D tar = target;
|
||||
Point2D tar = target.getPosition();
|
||||
boolean hasPathBelow = false;
|
||||
for (Path p : paths)
|
||||
{
|
||||
@@ -204,6 +217,9 @@ 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;
|
||||
@@ -258,6 +274,7 @@ public class Visitor
|
||||
if (random < 30)
|
||||
{
|
||||
Point2D position = null;
|
||||
DrawObject targetStage = null;
|
||||
for (Event e : agenda.getEvents())
|
||||
{
|
||||
if (convertMinutesToHours(startTime) > e.getStart() && convertMinutesToHours(startTime) < e.getStop())
|
||||
@@ -267,6 +284,7 @@ public class Visitor
|
||||
if (d.getFileName().equals(e.getStage().getName()))
|
||||
{
|
||||
position = d.getPosition();
|
||||
targetStage = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,7 +292,7 @@ public class Visitor
|
||||
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
|
||||
if (position != null)
|
||||
{
|
||||
actions.add(new Action(position, startTime, randomtime));
|
||||
actions.add(new Action(position, startTime, randomtime, targetStage));
|
||||
}
|
||||
startTime = startTime + randomtime;
|
||||
|
||||
@@ -282,6 +300,7 @@ public class Visitor
|
||||
else if (random >= 30 && random < 35)
|
||||
{
|
||||
Point2D position = null;
|
||||
DrawObject targetDraw = null;
|
||||
for (DrawObject d : objects)
|
||||
{
|
||||
if (d.getFileName().equals("entrance"))
|
||||
@@ -291,7 +310,7 @@ public class Visitor
|
||||
}
|
||||
if (position != null)
|
||||
{
|
||||
actions.add(new Action(position, startTime, 35));
|
||||
actions.add(new Action(position, startTime, 35, targetDraw));
|
||||
startTime = startTime + 35;
|
||||
}
|
||||
startTime = startTime + 35;
|
||||
@@ -300,6 +319,7 @@ public class Visitor
|
||||
else if (random > 35)
|
||||
{
|
||||
Point2D position = null;
|
||||
DrawObject targetDrawobj = null;
|
||||
for (DrawObject d : objects)
|
||||
{
|
||||
if (d.getFileName().equals("wc"))
|
||||
@@ -309,7 +329,7 @@ public class Visitor
|
||||
}
|
||||
if (position != null)
|
||||
{
|
||||
actions.add(new Action(position, startTime, 35));
|
||||
actions.add(new Action(position, startTime, 35, targetDrawobj));
|
||||
}
|
||||
startTime = startTime + 35;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user