Merge banaan dev

This commit is contained in:
Yorick
2015-04-08 14:27:19 +02:00
4 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ public class ControlPanel extends JPanel
peopleButton.addActionListener(new ActionListener(){ peopleButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
p.addVisitors(1); p.addVisitors();
} }
}); });
peoplePanel.add(peopleButton); peoplePanel.add(peopleButton);
+16 -3
View File
@@ -148,7 +148,6 @@ public class Panel extends JPanel implements ActionListener
addMouseWheelListener(new MouseWheel(this)); addMouseWheelListener(new MouseWheel(this));
addFocusListener(new WindowFocusListener(this)); addFocusListener(new WindowFocusListener(this));
t = new Timer(1000 / 10, this); t = new Timer(1000 / 10, this);
} }
@@ -220,14 +219,27 @@ public class Panel extends JPanel implements ActionListener
public void addVisitors() public void addVisitors()
{ {
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects)); ArrayList<DrawObject> entrances = new ArrayList<>();
for(DrawObject object : objects) {
if(object instanceof Entrance) {
entrances.add(object);
}
}
if(!entrances.isEmpty()) {
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
visitors.add(new Visitor("visitor",point, agenda, objects));
}
else {
JOptionPane.showMessageDialog(this, "You don't have a entrance");
}
} }
public void addVisitors(int count) public void addVisitors(int count)
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects)); addVisitors();
} }
} }
@@ -663,6 +675,7 @@ public class Panel extends JPanel implements ActionListener
case 4: case 4:
background = stone; background = stone;
break; break;
} }
repaint(); repaint();
} }
+2
View File
@@ -11,6 +11,7 @@ import javax.swing.SwingUtilities;
import Applicatie.Panel; import Applicatie.Panel;
import Applicatie.PathPopup; import Applicatie.PathPopup;
import Applicatie.Waypoint; import Applicatie.Waypoint;
import Applicatie.WaypointPopup; import Applicatie.WaypointPopup;
import Objects.DrawObject; import Objects.DrawObject;
@@ -78,6 +79,7 @@ public class Mouse extends MouseAdapter
if (o instanceof Waypoint) if (o instanceof Waypoint)
{ {
new WaypointPopup(o, panel); new WaypointPopup(o, panel);
} }
} }
if (o == selectedObject) if (o == selectedObject)
+3
View File
@@ -116,6 +116,7 @@ public class Path
return false; return false;
} }
public boolean intersectsRect(Rectangle2D rect) public boolean intersectsRect(Rectangle2D rect)
{ {
for (Shape line : getPath()) for (Shape line : getPath())
@@ -145,6 +146,7 @@ public class Path
lines.add(stroke.createStrokedShape(line)); lines.add(stroke.createStrokedShape(line));
} }
return lines; return lines;
} }
public void addWaypoint(int i, Panel panel) public void addWaypoint(int i, Panel panel)
@@ -160,6 +162,7 @@ public class Path
} }
/** /**
* Add a point to the path. * Add a point to the path.
* *