|
|
@@ -13,7 +13,7 @@ public class Visitor implements Serializable {
|
|
|
private Point2D positie, target;
|
|
|
private double rotation, speed;
|
|
|
private WalkingPath currentpath;
|
|
|
- private int currentpoint;
|
|
|
+ private int currentpoint, collisioncount;
|
|
|
private boolean walkInversed;
|
|
|
private double food, drink, pis;
|
|
|
ImageType image = ImageType.Visitor;
|
|
|
@@ -60,21 +60,20 @@ public class Visitor implements Serializable {
|
|
|
positie.getX() + speed * Math.cos(rotation),
|
|
|
positie.getY() + speed * Math.sin(rotation)
|
|
|
);
|
|
|
-
|
|
|
+ DrawEngine object = collisionObject(buildings);
|
|
|
this.food = (int)(Math.random()*100);
|
|
|
this.drink = (int)(Math.random()*100);
|
|
|
this.pis = (int)(Math.random()*100);
|
|
|
-
|
|
|
- if(hasCollision(visitors) || hasCollisionObject(buildings)) // collision with a ridged building or a visitor, rotate
|
|
|
+ if((hasCollision(visitors) && (collisioncount < 60 ) || hasCollisionObject(buildings) )) // collision with a ridged building or a visitor, rotate
|
|
|
{
|
|
|
positie = oldPositie;
|
|
|
rotation += 0.5*Math.random();
|
|
|
}
|
|
|
if(currentpath != null){
|
|
|
- DrawEngine object = collisionObject(buildings);
|
|
|
if(object != null){
|
|
|
if((currentpath.getObject1() == object && walkInversed) || (currentpath.getObject2() == object && !walkInversed)){ //end point reached, what to do?
|
|
|
if(object.type == SimulatorPane.Objects.STAGE){
|
|
|
+ setCollisionCount(0);
|
|
|
if(((SimulatorStage) object).getPlayingact() == null){
|
|
|
walkNewRoute(walkingpaths, object);
|
|
|
}
|
|
|
@@ -101,7 +100,6 @@ public class Visitor implements Serializable {
|
|
|
target = currentpath.get(currentpoint);
|
|
|
}
|
|
|
}else{ //entrance
|
|
|
- DrawEngine object = collisionObject(buildings);
|
|
|
if(object != null){
|
|
|
walkNewRoute(walkingpaths,object);
|
|
|
}
|
|
|
@@ -120,13 +118,12 @@ public class Visitor implements Serializable {
|
|
|
{
|
|
|
|
|
|
if(b != this && b.positie.distance(positie) < 11){
|
|
|
- double rotdifference = Math.toDegrees(Math.abs(rotation-b.rotation));
|
|
|
- if(!(rotdifference > 160 && rotdifference < 210)){
|
|
|
- return true;
|
|
|
- }
|
|
|
+ setCollisionCount(collisioncount + 1);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ setCollisionCount(collisioncount - 5);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -196,5 +193,11 @@ public class Visitor implements Serializable {
|
|
|
if(pis >= 0 && pis <= 100)
|
|
|
this.pis = pis;
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+ private void setCollisionCount(int c){
|
|
|
+ if(c >= 0 && c < 200){
|
|
|
+ collisioncount = c;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|