Ver Fonte

Visitors tweaking

jancoow há 10 anos atrás
pai
commit
002d55b85c

+ 1 - 1
src/gui/simulator/Sidebar.java

@@ -99,7 +99,7 @@ public class Sidebar implements Serializable  {
 		//ornaments
 		drawableOrnaments.put("Tree1", new Tree1(0, 0, 0.7, 1, this.terrain));
 		drawableOrnaments.put("PalmTree1", new PalmTree1(0, 0, 0.7, 1, this.terrain));
-		drawableOrnaments.put("Fence", new Fence(0, 0, 0.4, 1, this.terrain));
+		drawableOrnaments.put("Fence", new Fence(0, 0, 0.4, 0, this.terrain));
 
 		drawableArrays.add(drawableStages);
 		drawableArrays.add(drawableFacilities);

+ 15 - 12
src/gui/simulator/Visitor.java

@@ -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;
+		}
+	}
+}
+
+

+ 2 - 2
src/gui/simulator/facilities/Fence.java

@@ -15,11 +15,11 @@ public class Fence extends DrawEngine implements Serializable {
 
     //TODO Make this invisible
     public Fence(int x, int y, Terrain terrain) {
-        super(images, x, y, 1, 0, SimulatorPane.Objects.FENCE, terrain, new Rectangle2D.Double(-10, -10, 280, 50), true);
+        super(images, x, y, 1, 0, SimulatorPane.Objects.FENCE, terrain, new Rectangle2D.Double(-50, -20, 340, 60), true);
     }
 
     public Fence(int x, int y, double scale, double distance, Terrain terrain) {
-        super(images, x, y, scale, distance, SimulatorPane.Objects.FENCE, terrain, new Rectangle2D.Double(-10, -10, 280, 50), true);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.FENCE, terrain, new Rectangle2D.Double(-50, -20, 340, 60), true);
     }
     
     public String getFacilityName(){

+ 3 - 1
src/gui/simulator/facilities/WayPoint.java

@@ -1,5 +1,7 @@
 package gui.simulator.facilities;
 
+import java.awt.geom.Rectangle2D;
+
 import gui.simulator.DrawEngine;
 import gui.simulator.Images;
 import gui.simulator.SimulatorPane;
@@ -12,7 +14,7 @@ public class WayPoint extends DrawEngine implements Serializable{
 	private static String facilityName = "WayPoint";
 	
 	public WayPoint(int x, int y, double scale, double distance, Terrain terrain) {
-		super(ImageType.Crosspoint, x, y, scale, 1, SimulatorPane.Objects.WAYPOINT, terrain, null, false);
+		super(ImageType.Crosspoint, x, y, scale, 1, SimulatorPane.Objects.WAYPOINT, terrain, new Rectangle2D.Double(-30, -30, 150, 150), true);
 	}
 	
     public String getFacilityName(){