Bladeren bron

Added access + exit. Fixed some conflicts

Supermaniac101 10 jaren geleden
bovenliggende
commit
901f5345bd
4 gewijzigde bestanden met toevoegingen van 59 en 16 verwijderingen
  1. BIN
      res/simulator/uitgang.png
  2. 4 11
      src/gui/simulator/AccessPoint.java
  3. 48 1
      src/gui/simulator/ExitPoint.java
  4. 7 4
      src/gui/simulator/Terrain.java

BIN
res/simulator/uitgang.png


+ 4 - 11
src/gui/simulator/AccessPoint.java

@@ -1,6 +1,5 @@
 package gui.simulator;
 
-import gui.frames.MainFrame;
 
 public class AccessPoint extends Draw{
 	
@@ -8,10 +7,6 @@ public class AccessPoint extends Draw{
 	private static String facilityName = "Ingang";
 	private Terrain terrain;
 
-    public AccessPoint(Terrain terrain, int x, int y) {
-        super(imageLocation, x, y, 1, 0);
-        this.terrain = terrain;
-    }
 
     public AccessPoint(Terrain terrain, int x, int y, double scale, double distance) {
         super(imageLocation, x, y, scale, distance);
@@ -42,16 +37,14 @@ public class AccessPoint extends Draw{
 
     @Override
     public void setY(double y){
-    	double oldPosX = this.getX();
     	double oldPosY = this.getY();
     	if(y<50){
-    		this.setRotation(180);
+    		this.setRotation(0);
     		this.y = 50;     
-    	} else if(y>terrain.getLength()-150){
+    	} else if(y>11*terrain.getLength()/12){
     		this.setRotation(0);
-    		this.y = terrain.getLength()-150; 	
-    	} else if(x>1*terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
-    		this.x = oldPosX;
+    		this.y = 11*terrain.getLength()/12; 	
+    	} else if(x>terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
     		this.y = oldPosY;
     	} else {
     		this.y = y;

+ 48 - 1
src/gui/simulator/ExitPoint.java

@@ -1,5 +1,52 @@
 package gui.simulator;
 
-public class ExitPoint {
+public class ExitPoint extends Draw{
+	
+	private static String imageLocation = "/simulator/uitgang.png";
+	private static String facilityName = "Uitgang";
+	private Terrain terrain;
 
+
+    public ExitPoint(Terrain terrain, int x, int y, double scale, double distance) {
+        super(imageLocation, x, y, scale, distance);
+        this.terrain = terrain;
+    }
+    
+    public String getFacilityName(){
+    	return facilityName;
+    }
+    
+    @Override
+    public void setX(double x){
+    	double oldPosX = this.getX();
+    	double oldPosY = this.getY();
+    	if(x<0){
+    		this.setRotation(90);
+    		this.x = 0; 
+    	} else if(x>9*terrain.getWidth()/10){
+    		this.x = 9*terrain.getWidth()/10;
+    		this.setRotation(90);
+    	} else if(x>0 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
+    		this.x = oldPosX;
+    		this.y = oldPosY;
+    	} else {
+    		this.x = x;
+    	}
+    }
+
+    @Override
+    public void setY(double y){
+    	double oldPosY = this.getY();
+    	if(y<50){
+    		this.setRotation(0);
+    		this.y = 50;     
+    	} else if(y>11*terrain.getLength()/12){
+    		this.setRotation(0);
+    		this.y = 11*terrain.getLength()/12; 	
+    	} else if(x>terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
+    		this.y = oldPosY;
+    	} else {
+    		this.y = y;
+    	}
+    }
 }

+ 7 - 4
src/gui/simulator/Terrain.java

@@ -87,13 +87,13 @@ public class Terrain extends JPanel {
 		{
 			if(e.getY() < 300){
 				dragObject = new Stage((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
-			}else if(e.getY() > 300 && e.getY() < 550){
+			}else if(e.getY() > 300 && e.getY() < 500){
 				dragObject = new RestRoom((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
-			}else if(e.getY() > 550 && e.getY() < 800){
+			}else if(e.getY() > 500 && e.getY() < 700){
 				dragObject = new AccessPoint(this, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 			}
-			else if(e.getY() > 800 && e.getY() < 1100){
-				//dragObject = new custom facility
+			else if(e.getY() > 700 && e.getY() < 900){
+				dragObject = new ExitPoint(this, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 			}
 			entities.add(dragObject);
 		}
@@ -214,6 +214,9 @@ public class Terrain extends JPanel {
         Draw object3 = new AccessPoint(this, 0,550, 0.5, 10);
         object3.draw(g2);
         g2.drawString("ingang", 70, 675);
+        Draw object4 = new ExitPoint(this, 0,700, 0.5, 10);
+        object4.draw(g2);
+        g2.drawString("uitgang", 70, 800);
 		
 		//draw simulation field
 		g2.setClip(new Rectangle2D.Double(200, 0, getWidth()-200, getHeight()));