Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
911714f9b5 | ||
|
|
254167ba15 | ||
|
|
b8a7d9c02d |
+2
-2
@@ -34,8 +34,8 @@ public class Event implements Serializable {
|
|||||||
endHour, endMinute);
|
endHour, endMinute);
|
||||||
this.startHour = startHour;
|
this.startHour = startHour;
|
||||||
this.startMinute = startMinute;
|
this.startMinute = startMinute;
|
||||||
this.stopHour = stopHour;
|
this.stopHour = endHour;
|
||||||
this.stopMinute = stopMinute;
|
this.stopMinute = endMinute;
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.artist = artist;
|
this.artist = artist;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|||||||
+106
-139
@@ -19,8 +19,7 @@ import Objects.Entrance;
|
|||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
import Objects.Stage;
|
import Objects.Stage;
|
||||||
|
|
||||||
public class Visitor
|
public class Visitor {
|
||||||
{
|
|
||||||
|
|
||||||
Point2D position;
|
Point2D position;
|
||||||
double rotation;
|
double rotation;
|
||||||
@@ -35,8 +34,9 @@ public class Visitor
|
|||||||
int target;
|
int target;
|
||||||
int finalTarget;
|
int finalTarget;
|
||||||
|
|
||||||
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects, ArrayList<Waypoint> waypoints, GregorianCalendar date)
|
public Visitor(String filename, Point2D position, Agenda agenda,
|
||||||
{
|
ArrayList<DrawObject> objects, ArrayList<Waypoint> waypoints,
|
||||||
|
GregorianCalendar date) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.rotation = 0;
|
this.rotation = 0;
|
||||||
@@ -49,19 +49,20 @@ public class Visitor
|
|||||||
this.objects = objects;
|
this.objects = objects;
|
||||||
fillActions();
|
fillActions();
|
||||||
System.out.println(actions.size());
|
System.out.println(actions.size());
|
||||||
|
for (Action a : actions){
|
||||||
|
System.out.println("" + a.getStartTime());
|
||||||
|
}
|
||||||
target = 1;
|
target = 1;
|
||||||
finalTarget = 4;
|
finalTarget = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2)
|
public void draw(Graphics2D g2) {
|
||||||
{
|
|
||||||
AffineTransform tx = getTransform();
|
AffineTransform tx = getTransform();
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
g2.drawImage(image, tx, null);
|
g2.drawImage(image, tx, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AffineTransform getTransform()
|
private AffineTransform getTransform() {
|
||||||
{
|
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
AffineTransform tx = new AffineTransform();
|
AffineTransform tx = new AffineTransform();
|
||||||
tx.scale(scale, scale);
|
tx.scale(scale, scale);
|
||||||
@@ -70,26 +71,22 @@ public class Visitor
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawObject getEntrance()
|
public DrawObject getEntrance() {
|
||||||
{
|
for (DrawObject o : objects) {
|
||||||
for (DrawObject o : objects)
|
if (o instanceof Entrance) {
|
||||||
{
|
|
||||||
if (o instanceof Entrance)
|
|
||||||
{
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
|
public void update(ArrayList<DrawObject> objects, int currentTime,
|
||||||
{
|
ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel) {
|
||||||
DrawObject target = getEntrance();
|
DrawObject target = getEntrance();
|
||||||
for (Action a : actions)
|
for (Action a : actions) {
|
||||||
{
|
if (currentTime >= a.getStartTime()
|
||||||
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
|
&& currentTime < a.getStoptime()) {
|
||||||
{
|
finalTarget = a.getWaypoint().getSelf();
|
||||||
target = a.getTargetObject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -98,22 +95,19 @@ public class Visitor
|
|||||||
move(target, panel);
|
move(target, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(DrawObject tar, Panel panel)
|
public void move(DrawObject tar, Panel panel) {
|
||||||
{
|
|
||||||
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
||||||
|
|
||||||
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
|
double newRot = Math.atan2(targetPoint.getY() - position.getY(),
|
||||||
|
targetPoint.getX() - position.getX());
|
||||||
|
|
||||||
int difx = (int) (targetPoint.getX() - position.getX());
|
int difx = (int) (targetPoint.getX() - position.getX());
|
||||||
int dify = (int) (targetPoint.getY() - position.getY());
|
int dify = (int) (targetPoint.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10)
|
if (rotation > newRot && distance > 10) {
|
||||||
{
|
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
}
|
} else if (rotation < newRot && distance > 10) {
|
||||||
else if (rotation < newRot && distance > 10)
|
|
||||||
{
|
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,30 +117,26 @@ public class Visitor
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10)
|
if (distance > 10) {
|
||||||
{
|
position = new Point2D.Double(
|
||||||
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
(position.getX() + directionX * speed),
|
||||||
|
(position.getY() + directionY * speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects)
|
for (DrawObject object : objects) {
|
||||||
{
|
if (object instanceof Entrance || object instanceof Waypoint) {
|
||||||
if (object instanceof Entrance || object instanceof Waypoint)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (hasCollisionDO(object))
|
if (hasCollisionDO(object)) {
|
||||||
{
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false)
|
if (possible == false) {
|
||||||
{
|
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
if (checkIfOnWaypoint(panel))
|
if (checkIfOnWaypoint(panel)) {
|
||||||
{
|
|
||||||
// for(int i : panel.getWaypoint(target).getOptions())
|
// for(int i : panel.getWaypoint(target).getOptions())
|
||||||
// {
|
// {
|
||||||
// if(i == finalTarget)
|
// if(i == finalTarget)
|
||||||
@@ -154,18 +144,15 @@ public class Visitor
|
|||||||
// target = finalTarget;
|
// target = finalTarget;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// ArrayList<int[]> options = new ArrayList<int[]>();
|
// ArrayList<int[]> options = new ArrayList<int[]>();
|
||||||
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
|
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
|
||||||
for (Waypoint w : panel.getWaypoints())
|
for (Waypoint w : panel.getWaypoints()) {
|
||||||
{
|
|
||||||
options.put(w.getSelf(), w.getOptions());
|
options.put(w.getSelf(), w.getOptions());
|
||||||
}
|
}
|
||||||
for(Map.Entry<Integer, int[]> e : options.entrySet())
|
for (Map.Entry<Integer, int[]> e : options.entrySet()) {
|
||||||
{
|
|
||||||
System.out.println(e.getKey());
|
System.out.println(e.getKey());
|
||||||
System.out.println("=====================");
|
System.out.println("=====================");
|
||||||
for(int i : e.getValue())
|
for (int i : e.getValue()) {
|
||||||
{
|
|
||||||
System.out.println(i);
|
System.out.println(i);
|
||||||
}
|
}
|
||||||
System.out.println("----------");
|
System.out.println("----------");
|
||||||
@@ -174,47 +161,41 @@ public class Visitor
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkIfOnWaypoint(Panel panel)
|
public boolean checkIfOnWaypoint(Panel panel) {
|
||||||
{
|
if (panel.getWaypoint(target).contains(position)) {
|
||||||
if (panel.getWaypoint(target).contains(position))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveToTarget(DrawObject 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.getPosition();
|
Point2D tar = target.getPosition();
|
||||||
boolean hasPathBelow = false;
|
boolean hasPathBelow = false;
|
||||||
for (Path p : paths)
|
for (Path p : paths) {
|
||||||
{
|
if (p.containsPoint(position)) {
|
||||||
if (p.containsPoint(position))
|
|
||||||
{
|
|
||||||
hasPathBelow = true;
|
hasPathBelow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Shape containsShape = p.containsPointShape(position);
|
Shape containsShape = p.containsPointShape(position);
|
||||||
if (containsShape != null)
|
if (containsShape != null) {
|
||||||
{
|
tar = new Point2D.Double(
|
||||||
tar = new Point2D.Double(containsShape.getBounds().getCenterX(), containsShape.getBounds().getCenterY());
|
containsShape.getBounds().getCenterX(), containsShape
|
||||||
|
.getBounds().getCenterY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPathBelow)
|
if (hasPathBelow) {
|
||||||
{
|
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX()
|
||||||
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX() - position.getX());
|
- position.getX());
|
||||||
|
|
||||||
int difx = (int) (tar.getX() - position.getX());
|
int difx = (int) (tar.getX() - position.getX());
|
||||||
int dify = (int) (tar.getY() - position.getY());
|
int dify = (int) (tar.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10)
|
if (rotation > newRot && distance > 10) {
|
||||||
{
|
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
}
|
} else if (rotation < newRot && distance > 10) {
|
||||||
else if (rotation < newRot && distance > 10)
|
|
||||||
{
|
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,39 +205,30 @@ public class Visitor
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10)
|
if (distance > 10) {
|
||||||
{
|
position = new Point2D.Double((position.getX() + directionX
|
||||||
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
* speed), (position.getY() + directionY * speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects)
|
for (DrawObject object : objects) {
|
||||||
{
|
if (hasCollisionDO(object)) {
|
||||||
if (hasCollisionDO(object))
|
|
||||||
{
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Visitor object : visitors)
|
for (Visitor object : visitors) {
|
||||||
{
|
if (hasCollision(object) && object != this) {
|
||||||
if (hasCollision(object) && object != this)
|
|
||||||
{
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false)
|
if (possible == false) {
|
||||||
{
|
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
HashMap<Double, Shape> values = new HashMap<Double, Shape>();
|
HashMap<Double, Shape> values = new HashMap<Double, Shape>();
|
||||||
for (Path p : paths)
|
for (Path p : paths) {
|
||||||
{
|
for (Shape s : p.getPath()) {
|
||||||
for (Shape s : p.getPath())
|
|
||||||
{
|
|
||||||
Rectangle b = s.getBounds();
|
Rectangle b = s.getBounds();
|
||||||
double maxx = b.getMaxX();
|
double maxx = b.getMaxX();
|
||||||
double minx = b.getMinX();
|
double minx = b.getMinX();
|
||||||
@@ -270,16 +242,14 @@ public class Visitor
|
|||||||
points[3] = new Point2D.Double(maxx, maxy);
|
points[3] = new Point2D.Double(maxx, maxy);
|
||||||
|
|
||||||
Double lastdistance = null;
|
Double lastdistance = null;
|
||||||
for (Point2D.Double point : points)
|
for (Point2D.Double point : points) {
|
||||||
{
|
double distance = Point2D.distance(point.getX(),
|
||||||
double distance = Point2D.distance(point.getX(), point.getY(), position.getX(), position.getY());
|
point.getY(), position.getX(), position.getY());
|
||||||
if (lastdistance == null)
|
if (lastdistance == null) {
|
||||||
{
|
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (distance < lastdistance)
|
if (distance < lastdistance) {
|
||||||
{
|
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,35 +259,31 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
Double lastdistance = null;
|
Double lastdistance = null;
|
||||||
Shape lastShape = null;
|
Shape lastShape = null;
|
||||||
for (Map.Entry<Double, Shape> e : values.entrySet())
|
for (Map.Entry<Double, Shape> e : values.entrySet()) {
|
||||||
{
|
|
||||||
double distance = e.getKey();
|
double distance = e.getKey();
|
||||||
if (lastdistance == null)
|
if (lastdistance == null) {
|
||||||
{
|
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (distance < lastdistance)
|
if (distance < lastdistance) {
|
||||||
{
|
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastShape = values.get(lastdistance);
|
lastShape = values.get(lastdistance);
|
||||||
|
|
||||||
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds().getCenterX(), lastShape.getBounds().getCenterY());
|
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds()
|
||||||
|
.getCenterX(), lastShape.getBounds().getCenterY());
|
||||||
|
|
||||||
double newRot = Math.atan2(target2.getY() - position.getY(), target2.getX() - position.getX());
|
double newRot = Math.atan2(target2.getY() - position.getY(),
|
||||||
|
target2.getX() - position.getX());
|
||||||
|
|
||||||
int difx = (int) (target2.getX() - position.getX());
|
int difx = (int) (target2.getX() - position.getX());
|
||||||
int dify = (int) (target2.getY() - position.getY());
|
int dify = (int) (target2.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10)
|
if (rotation > newRot && distance > 10) {
|
||||||
{
|
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
}
|
} else if (rotation < newRot && distance > 10) {
|
||||||
else if (rotation < newRot && distance > 10)
|
|
||||||
{
|
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,42 +293,37 @@ public class Visitor
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10)
|
if (distance > 10) {
|
||||||
{
|
position = new Point2D.Double((position.getX() + directionX
|
||||||
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
* speed), (position.getY() + directionY * speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects)
|
for (DrawObject object : objects) {
|
||||||
{
|
if (hasCollisionDO(object)) {
|
||||||
if (hasCollisionDO(object))
|
|
||||||
{
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Visitor object : visitors)
|
for (Visitor object : visitors) {
|
||||||
{
|
if (hasCollision(object) && object != this) {
|
||||||
if (hasCollision(object) && object != this)
|
|
||||||
{
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false)
|
if (possible == false) {
|
||||||
{
|
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
public void fillActions() {
|
public void fillActions() {
|
||||||
int startTime = 540;
|
int startTime = 540;
|
||||||
int stopTime = 1260;
|
int stopTime = 1260;
|
||||||
|
|
||||||
while (startTime < stopTime) {
|
while (startTime < stopTime) {
|
||||||
int random = (int) Math.floor(Math.random() * 21);
|
int random = (int) Math.floor(Math.random() * 51);
|
||||||
if (random < 40) {
|
if (random < 30) {
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetStage = null;
|
||||||
ArrayList<Event> posEvents = new ArrayList<Event>();
|
ArrayList<Event> posEvents = new ArrayList<Event>();
|
||||||
@@ -377,12 +338,14 @@ public class Visitor
|
|||||||
totalPopularity += ev.getExpectedPopularity();
|
totalPopularity += ev.getExpectedPopularity();
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = (int) Math.floor(Math.random() * totalPopularity);
|
Random rand = new Random();
|
||||||
|
int n = rand.nextInt(totalPopularity) + 1;
|
||||||
int currentPop = 0;
|
int currentPop = 0;
|
||||||
|
if (posEvents != null){
|
||||||
for (Event evs : posEvents){
|
for (Event evs : posEvents){
|
||||||
int before = currentPop;
|
int before = currentPop;
|
||||||
currentPop += evs.getExpectedPopularity();
|
currentPop = currentPop + evs.getExpectedPopularity();
|
||||||
if (currentPop >= r && before < r){
|
if (before < n && currentPop >= n){
|
||||||
for (DrawObject d : objects) {
|
for (DrawObject d : objects) {
|
||||||
if (d.getFileName().equals("stage")) {
|
if (d.getFileName().equals("stage")) {
|
||||||
Stage s = (Stage) d;
|
Stage s = (Stage) d;
|
||||||
@@ -395,15 +358,17 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
|
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
Waypoint w = getClosedWaypoint(position);
|
Waypoint w = getClosedWaypoint(position);
|
||||||
actions.add(new Action(position, startTime, randomtime, targetStage, w));
|
actions.add(new Action(position, startTime, randomtime,
|
||||||
|
targetStage, w));
|
||||||
}
|
}
|
||||||
startTime = startTime + randomtime;
|
startTime = startTime + randomtime;
|
||||||
|
|
||||||
} else if (random >= 40 && random < 45) {
|
} else if (random >= 30 && random < 40) {
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetStage = null;
|
||||||
ArrayList<DrawObject> foodPlaces = new ArrayList<DrawObject>();
|
ArrayList<DrawObject> foodPlaces = new ArrayList<DrawObject>();
|
||||||
@@ -413,17 +378,18 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foodPlaces.size() != 0){
|
if (foodPlaces.size() != 0) {
|
||||||
int r = (int) Math.floor(Math.random() * foodPlaces.size());
|
int r = (int) Math.floor(Math.random() * foodPlaces.size());
|
||||||
position = foodPlaces.get(r).getPosition();
|
position = foodPlaces.get(r).getPosition();
|
||||||
targetStage = foodPlaces.get(r);
|
targetStage = foodPlaces.get(r);
|
||||||
Waypoint w = getClosedWaypoint(position);
|
Waypoint w = getClosedWaypoint(position);
|
||||||
actions.add(new Action(position, startTime, 35, targetStage, w));
|
actions.add(new Action(position, startTime, 35,
|
||||||
|
targetStage, w));
|
||||||
startTime = startTime + 20;
|
startTime = startTime + 20;
|
||||||
}
|
}
|
||||||
startTime = startTime + 35;
|
startTime = startTime + 35;
|
||||||
|
|
||||||
} else if (random > 45) {
|
} else if (random >= 40) {
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetStage = null;
|
||||||
ArrayList<DrawObject> toilets = new ArrayList<DrawObject>();
|
ArrayList<DrawObject> toilets = new ArrayList<DrawObject>();
|
||||||
@@ -432,12 +398,13 @@ public class Visitor
|
|||||||
toilets.add(d);
|
toilets.add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toilets.size() != 0){
|
if (toilets.size() != 0) {
|
||||||
int r = (int) Math.floor(Math.random() * toilets.size());
|
int r = (int) Math.floor(Math.random() * toilets.size());
|
||||||
position = toilets.get(r).getPosition();
|
position = toilets.get(r).getPosition();
|
||||||
targetStage = toilets.get(r);
|
targetStage = toilets.get(r);
|
||||||
Waypoint w = getClosedWaypoint(position);
|
Waypoint w = getClosedWaypoint(position);
|
||||||
actions.add(new Action(position, startTime, 35, targetStage, w));
|
actions.add(new Action(position, startTime, 35,
|
||||||
|
targetStage, w));
|
||||||
startTime = startTime + 20;
|
startTime = startTime + 20;
|
||||||
}
|
}
|
||||||
startTime = startTime + 35;
|
startTime = startTime + 35;
|
||||||
@@ -446,11 +413,11 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint getClosedWaypoint(Point2D point){
|
public Waypoint getClosedWaypoint(Point2D point) {
|
||||||
Waypoint waypoint = null;
|
Waypoint waypoint = null;
|
||||||
int distance = 10000;
|
int distance = 10000;
|
||||||
for(Waypoint w : waypoints){
|
for (Waypoint w : waypoints) {
|
||||||
if (w.getPosition().distance(point) < distance){
|
if (w.getPosition().distance(point) < distance) {
|
||||||
waypoint = w;
|
waypoint = w;
|
||||||
distance = (int) w.getPosition().distance(point);
|
distance = (int) w.getPosition().distance(point);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user