Răsfoiți Sursa

Some more improvements. People will leave the festival

jancoow 10 ani în urmă
părinte
comite
d8af2b3ab5

+ 15 - 1
src/agenda/Agenda.java

@@ -67,7 +67,21 @@ public class Agenda implements Serializable {
         Collections.sort(actTimes);
         return actTimes.get(0);
     }
-
+    
+    /**
+     *  returns the first ActTime of all the acts.
+     * @return first ActTime of all acts
+     */
+    public ActTime lastActTime(){
+        List<Act> acts = this.getActs();
+        List<ActTime> actTimes = new ArrayList<ActTime>();
+        for(Act act: acts){
+            actTimes.add(act.getActTime());
+        }
+        Collections.sort(actTimes, Collections.reverseOrder());
+        return actTimes.get(0);
+    }
+    
     /**
      *
      * @param time GregorianCalendar, remember month -1!

+ 1 - 24
src/gui/menubar/MenuBar.java

@@ -56,9 +56,6 @@ public class MenuBar extends JMenuBar{
 		JMenuItem newAction = new JMenuItem("New");
 		JMenuItem openAction = new JMenuItem("Open");
 		JMenuItem exitAction = new JMenuItem("Exit");
-		JMenuItem cutAction = new JMenuItem("Cut");
-		JMenuItem copyAction = new JMenuItem("Copy");
-		JMenuItem pasteAction = new JMenuItem("Paste");
 		JMenuItem saveAction = new JMenuItem("Save");
 		JMenuItem helpAction = new JMenuItem("Help");
 		JMenuItem uploadAction = new JMenuItem("Upload agenda to DB");
@@ -73,9 +70,6 @@ public class MenuBar extends JMenuBar{
 		newAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
 		openAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
 		exitAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
-		cutAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
-		copyAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
-		pasteAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
 		saveAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK));
 		uploadAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,ActionEvent.CTRL_MASK));
 
@@ -128,6 +122,7 @@ public class MenuBar extends JMenuBar{
 		fileMenu.add(openSim);
 		openSim.addActionListener(new ActionListener() {
 
+			@SuppressWarnings("unchecked")
 			public void actionPerformed(ActionEvent e) {
 				try {
 					List <Object> list = new ArrayList<Object>();
@@ -183,24 +178,6 @@ public class MenuBar extends JMenuBar{
 				System.exit(0);
 			}
 		});
-		editMenu.add(cutAction);
-		cutAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				System.out.println("You have clicked on the cut action");
-			}
-		});
-		editMenu.add(copyAction);
-		copyAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				System.out.println("You have clicked on the copy action");
-			}
-		});
-		editMenu.add(pasteAction);
-		pasteAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				System.out.println("You have clicked on the paste action");
-			}
-		});
 
 		//view
 		viewMenu.add(editorView);

+ 0 - 1
src/gui/panels/agenda/InfoPane.java

@@ -1,6 +1,5 @@
 package gui.panels.agenda;
 
-import java.awt.Color;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;

+ 1 - 1
src/gui/panels/edit/EditPane.java

@@ -14,6 +14,7 @@ import agenda.Agenda;
 /**
  * Created by gjoosen on 13/02/15.
  */
+@SuppressWarnings("serial")
 public class EditPane extends JPanel {
 
     private Agenda agenda;
@@ -44,7 +45,6 @@ public class EditPane extends JPanel {
         detailsPanel.add(randomPane, BorderLayout.WEST);
         detailsPanel.add(randomPane, BorderLayout.SOUTH);
         detailsPanel.add(new Label("Details"), BorderLayout.NORTH);
-        detailsPanel.add(new JTextArea("Test"), BorderLayout.CENTER);
         return detailsPanel;
     }
 }

+ 0 - 3
src/gui/panels/edit/StagesPane.java

@@ -25,7 +25,6 @@ public class StagesPane extends JPanel {
     private final Agenda agenda;
     private DefaultListModel model;
     
-    private JPanel detailsPanel;
     private JLabel title;
     
     public StagesPane(Agenda agenda, JPanel detailsPanel){
@@ -36,7 +35,6 @@ public class StagesPane extends JPanel {
     	this.setOpaque(false);
         this.setBackground(Color.WHITE);
         this.agenda = agenda;
-        this.detailsPanel = detailsPanel;
         super.setBackground(new Color(242,241,237));
         super.setLayout(new BorderLayout());
         super.add(title, BorderLayout.NORTH);
@@ -203,7 +201,6 @@ class DoubleClickStage extends MouseAdapter {
             ListModel dlm = list.getModel();
             Object item = dlm.getElementAt(index);;
             list.ensureIndexIsVisible(index);
-            System.out.println("Double clicked on " + item);
             this.pane.editDialog();
         }
     }

+ 1 - 0
src/gui/simulator/Images.java

@@ -16,6 +16,7 @@ import javax.imageio.ImageIO;
 
 public class Images implements Serializable{
 
+	private static final long serialVersionUID = -4830134412879352158L;
 	public transient  static ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
 	public transient static ArrayList<TexturePaint> tp = new ArrayList<TexturePaint>();
 

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

@@ -28,6 +28,7 @@ import java.util.LinkedHashMap;
 import java.util.Map.Entry;
 
 public class Sidebar implements Serializable  {
+	private static final long serialVersionUID = 5844093695389256330L;
 	private int sideBarWidth;
 	private int sideBarHeight;
 	private Terrain terrain;

+ 3 - 5
src/gui/simulator/SimIo.java

@@ -7,7 +7,6 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
-import java.util.LinkedList;
 import java.util.List;
 
 import javax.swing.JFileChooser;
@@ -18,8 +17,7 @@ public class SimIo {
 	public static void writeIo(List<Object> list) throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser(); 
-		if(fileChooser.showSaveDialog(null)
-				== fileChooser.APPROVE_OPTION) {
+		if(fileChooser.showSaveDialog(null)	== JFileChooser.APPROVE_OPTION) {
 			java.io.File file = fileChooser.getSelectedFile();
 			ObjectOutputStream output = null;
 			try{
@@ -38,13 +36,13 @@ public class SimIo {
 
 	}
 
+	@SuppressWarnings("unchecked")
 	public static List<Object> readIo() throws IOException
 	{
 		List<Object> objectlist = new ArrayList<Object>();
 
 		JFileChooser fileChooser = new JFileChooser();
-		if(fileChooser.showOpenDialog(null)
-				== fileChooser.APPROVE_OPTION) {
+		if(fileChooser.showOpenDialog(null)	== JFileChooser.APPROVE_OPTION) {
 			java.io.File file = fileChooser.getSelectedFile();
 
 			ObjectInputStream input = null;

+ 9 - 2
src/gui/simulator/SimulatorPane.java

@@ -14,7 +14,7 @@ import agenda.Agenda;
 @SuppressWarnings("serial")
 public class SimulatorPane extends JPanel{
 	private Terrain terrain;
-	private Timer framestimer, updatetimer;
+	private Timer framestimer, updatetimer, checktimer;
 	
 	//terrain type enums
 	public enum Terrains{BEACH, GRASS, URBAN, UNDEFINED};
@@ -42,6 +42,13 @@ public class SimulatorPane extends JPanel{
 				terrain.calculate();
 			}
 		});
+	    checktimer = new Timer(2000, new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent arg0) {
+				terrain.checkPlayingActs();;
+			}
+		});
+	    checktimer.start();
         framestimer.start();
 	}
 	
@@ -52,7 +59,7 @@ public class SimulatorPane extends JPanel{
 		case FASTER:
 			updatetimer.setDelay(1000/100); break;
 		case PLAY:
-			updatetimer.start(); updatetimer.setDelay(1000/50); break;
+			updatetimer.start();  updatetimer.setDelay(1000/50); break;
 		case PAUZE:
 			updatetimer.stop(); break;
 		case STOP:

+ 96 - 101
src/gui/simulator/Terrain.java

@@ -17,7 +17,6 @@ import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.Shape;
-import java.awt.TexturePaint;
 import java.awt.Toolkit;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
@@ -30,6 +29,8 @@ import java.awt.geom.NoninvertibleTransformException;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -41,36 +42,31 @@ import agenda.Act;
 import agenda.Agenda;
 
 
+@SuppressWarnings("serial")
 public class Terrain extends JPanel {
 
 	private List<DrawEngine> entities;
-	private Point2D oldPosition;
+	private ArrayList<Visitor> visitors;
+	private WalkingPathArrayList paths;
+	
+	private Point2D oldPosition, lastClickPosition,lastMovedMousePosition ;
 	private double oldRotation, oldScale;
 	private DrawEngine dragObject, selectedObject;
-	private static TextPaint background;
+
 	private Sidebar sidebar;
 	private Topbar topbar;
+	private Agenda agenda;
+	private WalkingPath currentpath;
 
-	private int festivalheight, festivalwidth;
+	private static TextPaint background;
+	private int festivalheight, festivalwidth, pathgenerate, maxvisitors; 
 	private int sideBarWidth = 200;
 
-	private int pathgenerate, maxvisitors; 
-	private WalkingPath currentpath;
-
 	Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
 	float cameraScale = 1;
-	private boolean grid;
-	private ArrayList<Visitor> visitors;
-	private WalkingPathArrayList paths;
+	private boolean grid, lastplayedact;
 	transient Cursor rotate, pathpoint;
-
-	Point2D lastClickPosition;
-	Point lastMousePosition;
-	Point2D lastMovedMousePosition;
-	TexturePaint p;
-
-	private Agenda agenda;
-
+	private Point lastMousePosition;
 	public enum Location{NORTH, EAST, SOUTH, WEST};
 
 	public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda, SimulatorPane simulator){
@@ -98,10 +94,13 @@ public class Terrain extends JPanel {
 		case URBAN:
 			background = Images.TextPaint.TPTerrainStreet;
 			break;
+		case UNDEFINED:
+			break;
+		default:
+			break;
 		}
 
-		this.entities = new LinkedList();
-		this.initEntities();
+		this.entities = new LinkedList<DrawEngine>();
 		this.listeners();
 		this.agenda = agenda;
 	}
@@ -140,16 +139,12 @@ public class Terrain extends JPanel {
 
 								//double click
 								if(e.getClickCount() == 2){
-									//TODO open dialog
 									JDialog dialog = new StageDialog(drawObject, agenda);
-
 									//position
 									Toolkit toolkit = Toolkit.getDefaultToolkit();
 									Dimension screenSize = toolkit.getScreenSize();
-
 									int x = (int) ((screenSize.getWidth() - dialog.getWidth()) / 2);
 									int y = (int) ((screenSize.getHeight() - dialog.getHeight()) / 2);
-
 									Point center = new Point(x, y);
 
 									dialog.setLocation(center);
@@ -228,7 +223,7 @@ public class Terrain extends JPanel {
 				Point2D clickPoint = getClickPoint(e.getPoint());
 				if(dragObject != null){
 					if(SwingUtilities.isLeftMouseButton(e) && (dragObject instanceof AccessPoint || dragObject instanceof ExitPoint)){    
-						if(e.getX()<200){
+						if(clickPoint.getX()<200){
 							dragObject.changeLocation(Location.WEST);
 							dragObject.setX(-75);
 							dragObject.setRotation(90);
@@ -239,8 +234,8 @@ public class Terrain extends JPanel {
 							} else {
 								dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));    
 							}   
-						} else if (e.getX()>200 && e.getX()< getFestivalWidth()-200){
-							if(e.getY()<(getFestivalHeight()/2)){
+						} else if (clickPoint.getX()>200 && clickPoint.getX()< getFestivalWidth()-200){
+							if(clickPoint.getY()<(getFestivalHeight()/2)){
 								dragObject.changeLocation(Location.NORTH);
 								dragObject.setY(0);
 								dragObject.setRotation(180);
@@ -253,7 +248,7 @@ public class Terrain extends JPanel {
 									dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));  
 								}   
 
-							} else if(e.getY()>(getFestivalHeight()/2)){
+							} else if(clickPoint.getY()>(getFestivalHeight()/2)){
 								dragObject.changeLocation(Location.SOUTH);
 								dragObject.setY(getFestivalHeight()-75);
 								dragObject.setRotation(180);
@@ -266,7 +261,7 @@ public class Terrain extends JPanel {
 									dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));  
 								}    
 							}
-						} else if(e.getX()>getFestivalWidth()-200){
+						} else if(clickPoint.getX()>getFestivalWidth()-200){
 							dragObject.changeLocation(Location.EAST);
 							dragObject.setX(getFestivalWidth()-125);
 							dragObject.setRotation(90);
@@ -321,7 +316,6 @@ public class Terrain extends JPanel {
 						} else {
 							object.setScale(object.getScale() * 1 + (e.getPreciseWheelRotation()/10.0));
 						}
-
 						//intersect
 						for(DrawEngine draw: entities){
 							if(draw != object){
@@ -330,7 +324,6 @@ public class Terrain extends JPanel {
 								}
 							}
 						}
-
 						repaint();
 						return;
 					}
@@ -342,13 +335,7 @@ public class Terrain extends JPanel {
 		});
 	}
 
-	/*
-	 * Add facilities on initializing
-	 */
-	private void initEntities(){
-		//this.entities.add(new Stage(300, 10, 0.5, 10));
-		//this.entities.add(new Stage(400, 40, 2, 10));
-	}
+
 
 	public void paintComponent(Graphics g) {
 		super.paintComponent(g);
@@ -360,7 +347,7 @@ public class Terrain extends JPanel {
 		//draw simulation field
 		Area a1 = new Area(new Rectangle2D.Double(sideBarWidth, 0, getWidth()-sideBarWidth, getHeight()));
 		Area a2 = new Area(topbar.getBackground());
-		a2.transform(new AffineTransform().getTranslateInstance(1, 1.2));
+		a2.transform(AffineTransform.getTranslateInstance(1, 1.2));
 		a1.subtract(a2);  
 
 		g2.setClip(a1);
@@ -368,11 +355,9 @@ public class Terrain extends JPanel {
 		g2.translate(sideBarWidth,0);
 		g2.setTransform(getCamera());
 
-
 		g2.setPaint(Images.getTextPaint(background));
 		g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
 
-
 		if(grid){
 			g2.setColor(new Color(160,160,160,120));
 			g2.setStroke(new BasicStroke(1));
@@ -418,7 +403,7 @@ public class Terrain extends JPanel {
 					}
 				}
 			}
-
+			
 			if(collide){
 				g2.setColor(new Color(254, 0, 0, 128));
 			}else{
@@ -430,12 +415,6 @@ public class Terrain extends JPanel {
 		g2.setClip(null);
 	}
 
-	private Rectangle drawDragRectangle(DrawEngine shape){
-		Rectangle rectangle = null;
-		rectangle = new Rectangle((int) (shape.getX() - shape.getDistanceToOtherObjects()), (int) (shape.getY() - shape.getDistanceToOtherObjects()), (int) (shape.getWidth() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())), (int) (shape.getHeight() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())));
-		return rectangle;
-	}
-
 	private boolean intersection(DrawEngine d1, DrawEngine d2){
 		Area area = new Area(d1.getAffineTransform().createTransformedShape(d1.getRect()));
 		Area area2 = new Area(d2.getAffineTransform().createTransformedShape(d2.getRect()));
@@ -455,64 +434,99 @@ public class Terrain extends JPanel {
 
 	private AffineTransform getCamera() {
 		AffineTransform tx = new AffineTransform();
-		//start field in top left corner, next to sidebar
 		tx.translate(-cameraPoint.getX() + sideBarWidth, -cameraPoint.getY());
-		//start field in middle of screen
-		//tx.translate(-cameraPoint.getX() + getWidth()/2, -cameraPoint.getY() + getHeight()/2);
 		tx.scale(cameraScale, cameraScale);
 		return tx;
 	}
 	public void calculate(){
-		for(Visitor v:visitors){
-			v.update(visitors, entities,paths);
+		try{
+		Iterator<Visitor> i = visitors.iterator();
+		while(i.hasNext()){
+			i.next().update(visitors, entities,paths);
 		}
-		if(Math.random()*500 <100){
+		}catch(ConcurrentModificationException e){
+			
+		}
+		if(visitors.size() < maxvisitors && Math.random()*500 <100 && !lastplayedact){
 			Point2D startpoint = null;
+			List<AccessPoint> entrances = new ArrayList<AccessPoint>();
 			for(DrawEngine e:entities){
-				List<AccessPoint> entrances = new ArrayList<AccessPoint>();
-				if(e.type == Objects.ENTRANCE){
+				if(e.type == Objects.ENTRANCE)
 					entrances.add((AccessPoint)e);
-				}
-				if(!entrances.isEmpty())
-					startpoint = entrances.get((int)(Math.random()*entrances.size())).getCenter();
 			}
-			if(startpoint == null || visitors.size() >= maxvisitors) return; //No entrance found OR to many visitors, stop adding people. 
-			visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint));
+			if(!entrances.isEmpty())
+				startpoint = entrances.get((int)(Math.random()*entrances.size())).getCenter();
+			if(startpoint != null)  //No entrance found , stop adding people. 
+				visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint, this));
 		}
 		topbar.recalculate();
+	}
+
+	public void checkPlayingActs(){
+		if(agenda.lastActTime().getEndTime().getTimeInMillis() <= topbar.getTime().getTimeInMillis())
+			lastplayedact = true;
 		stageloop:
-			for(DrawEngine object:entities){
-				if(object.type == SimulatorPane.Objects.STAGE){
-					SimulatorStage stage = (SimulatorStage)object;
-					for(Act act:agenda.getCurrentActs(topbar.getTime())){
-						if(act.getStage() == stage.getStage()){
-							stage.setPlayingact(act);
-							continue stageloop;
-						}
+		for(DrawEngine object:entities){
+			if(object.type == SimulatorPane.Objects.STAGE){
+				SimulatorStage stage = (SimulatorStage)object;
+				for(Act act:agenda.getCurrentActs(topbar.getTime())){
+					if(act.getStage() == stage.getStage()){
+						stage.setPlayingact(act);
+						continue stageloop;
 					}
-					stage.setPlayingact(null);
 				}
+				stage.setPlayingact(null);
 			}
+		}
 	}
+	public void newWalkingPath(Images.TextPaint texture){
+		if(pathgenerate == 0){
+			currentpath = new WalkingPath(texture);
+			pathgenerate = 1;
+		}
+	}
+	public void removeWalkingPaths(DrawEngine object){
+		for(WalkingPath p:paths.getWalkingPadObject(object)){
+			paths.remove(p);
+		}
+	}
+	
+	public void createCustomCursors(){
+		Toolkit toolkit = Toolkit.getDefaultToolkit();  
+		ImageType image;
+
+		image = ImageType.RotateCursor;
+		rotate = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Rotate");  
 
+		image = ImageType.PathCursor;
+		pathpoint = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Pathpoint");  
+	}
+	public void clearVisitors(){
+		visitors.clear();
+	}
+	public void removeVisitor(Visitor v){
+		visitors.remove(v);
+	}
+	
+	//getters and setters 
+	
 	public void setFestivalHeight(int height){
 		this.festivalheight = height;
 	}
-	public void setFestivalWidth(int width){
-		this.festivalwidth = width;
-	}
 	public int getFestivalHeight(){
 		return festivalheight;
 	}
+	
+	public void setFestivalWidth(int width){
+		this.festivalwidth = width;
+	}
 	public int getFestivalWidth(){
 		return festivalwidth;
 	}
-
-	//getters and setters for sidebar
+	
 	public void setDragObject(DrawEngine dragObject){
 		this.dragObject = dragObject;
 	}
-
 	public DrawEngine getDragObject(){
 		return dragObject;
 	}
@@ -521,42 +535,20 @@ public class Terrain extends JPanel {
 		entities.add(dragObject);
 	}
 
-	public void createCustomCursors(){
-		Toolkit toolkit = Toolkit.getDefaultToolkit();  
-		ImageType image;
-
-		image = ImageType.RotateCursor;
-		rotate = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Rotate");  
-
-		image = ImageType.PathCursor;
-		pathpoint = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Pathpoint");  
-	}
 	public void toggleGrid(){
 		grid = !grid;
 	}
-	public void newWalkingPath(Images.TextPaint texture){
-		if(pathgenerate == 0){
-			currentpath = new WalkingPath(texture);
-			pathgenerate = 1;
-		}
-	}
+
 	public List<DrawEngine> getEntities() {
 		return entities;
 	}
-	public void clearVisitors(){
-		visitors.clear();
-	}
+	
 	public void setMaxVisitors(int v){
 		this.maxvisitors = v;
 	}
 	public int getMaxVisitors(){
 		return maxvisitors;
 	}
-	public void removeWalkingPaths(DrawEngine object){
-		for(WalkingPath p:paths.getWalkingPadObject(object)){
-			paths.remove(p);
-		}
-	}
 
 	public void setEntities(List<DrawEngine> entities) {
 		this.entities = entities;
@@ -565,9 +557,12 @@ public class Terrain extends JPanel {
 	public void setPaths(WalkingPathArrayList paths) {
 		this.paths = paths;
 	}
-
 	public WalkingPathArrayList getPaths() {
 		return paths;
 	}
 
+	public boolean isLastplayedact() {
+		return lastplayedact;
+	}
+	
 }

+ 13 - 6
src/gui/simulator/Visitor.java

@@ -16,8 +16,9 @@ public class Visitor {
 	private int currentpoint, collisioncount;
 	private boolean walkInversed;
 	private double food, drink, pee;
+	private Terrain terrain;
 	
-	public Visitor(Point2D positie, Point2D starttarget) {
+	public Visitor(Point2D positie, Point2D starttarget, Terrain terrain) {
 		this.positie = positie;
 		this.rotation = 0;
 		this.speed = 1 + Math.random();
@@ -25,6 +26,7 @@ public class Visitor {
 		this.food = (int)(Math.random()*100);
 		this.drink = (int)(Math.random()*100);
 		this.pee = (int)(Math.random()*100);
+		this.terrain = terrain;
 	}
 
 	void update(List<Visitor> visitors, List<DrawEngine> buildings, WalkingPathArrayList walkingpaths)
@@ -62,20 +64,21 @@ public class Visitor {
 					if(object.type == SimulatorPane.Objects.STAGE){ //stay at stage when a act is playing
 						setCollisionCount(0);
 						if(((SimulatorStage) object).getPlayingact() == null){
-							walkNewRoute(walkingpaths, object);
+						}else{
+							return;
 						}
 					}else if(object.type == SimulatorPane.Objects.DRINK){ //buy a drink
 						setDrink(getDrink() + 50);
-						walkNewRoute(walkingpaths, object);
 					}else if(object.type == SimulatorPane.Objects.SNACKBAR){ //buy some food
 						setFood(getFood() + 50);
-						walkNewRoute(walkingpaths, object);
 					}else if(object.type == SimulatorPane.Objects.RESTROOM){ //toilet
 						setPee(100);
-						walkNewRoute(walkingpaths, object);
 					}else if(object.type == SimulatorPane.Objects.WAYPOINT){ //waypoint, choose a new route
-						walkNewRoute(walkingpaths, object);
+					}else if(object.type == SimulatorPane.Objects.EXIT){
+						terrain.removeVisitor(this);
+						return;
 					}
+					walkNewRoute(walkingpaths, object);
 				}
 			}
 			if(positie.distance(currentpath.get(currentpoint)) < 11){ //collision with a path-point
@@ -140,6 +143,10 @@ public class Visitor {
 	private void walkNewRoute(WalkingPathArrayList walkingpaths, DrawEngine object){
 		WalkingPathArrayList connectedWalkingPaths = walkingpaths.getWalkingPadObject(object);
 		connectedWalkingPaths.removeType(object, SimulatorPane.Objects.ENTRANCE);
+		if(terrain.isLastplayedact())
+			connectedWalkingPaths.removeType(object, SimulatorPane.Objects.STAGE);
+		else
+			connectedWalkingPaths.removeType(object, SimulatorPane.Objects.EXIT);
 		if(food > 25)  connectedWalkingPaths.removeType(object, SimulatorPane.Objects.SNACKBAR);
 		if(drink > 25) connectedWalkingPaths.removeType(object, SimulatorPane.Objects.DRINK);
 		if(pee > 25)   connectedWalkingPaths.removeType(object, SimulatorPane.Objects.RESTROOM);

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

@@ -16,11 +16,11 @@ public class AccessPoint extends DrawEngine implements Serializable {
     }
 
     public AccessPoint(Terrain terrain, int x, int y, double scale, double distance) {
-        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(-10, -10, 430, 170), false);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(100, -10, 200, 170), false);
     }
     
     public AccessPoint(int x, int y, double scale, double distance, Terrain terrain) {
-        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(-10, -10, 430, 170), false);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(100, -10, 200, 170), false);
     }