From 8167fec369bff1941f9f9aee7669c4df6490e95d Mon Sep 17 00:00:00 2001 From: Yorick Date: Wed, 8 Apr 2015 20:31:18 +0200 Subject: [PATCH] WOOOOOOOOOOOOOOOOOOOO --- Agenda/Event.java | 4 +-- Applicatie/Panel.java | 2 +- Applicatie/Visitor.java | 66 +++++++++++++++++++++++++---------------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/Agenda/Event.java b/Agenda/Event.java index 90acfb5..baf2fd4 100644 --- a/Agenda/Event.java +++ b/Agenda/Event.java @@ -55,11 +55,11 @@ public class Event implements Serializable { } public int getStart(){ - return (startHour * 100) + startMinute; + return (startHour * 60) + startMinute; } public int getStop(){ - return (stopHour * 100) + stopMinute; + return (stopHour * 60) + stopMinute; } public int getStopHour(){ diff --git a/Applicatie/Panel.java b/Applicatie/Panel.java index f9bb2fc..d69710b 100644 --- a/Applicatie/Panel.java +++ b/Applicatie/Panel.java @@ -148,7 +148,7 @@ public class Panel extends JPanel implements ActionListener addMouseWheelListener(new MouseWheel(this)); addFocusListener(new WindowFocusListener(this)); - t = new Timer(1000 / 100, this); + t = new Timer(1000 / 10, this); } public int getPanelInfoLength() diff --git a/Applicatie/Visitor.java b/Applicatie/Visitor.java index 8498b4a..bf3ec7f 100644 --- a/Applicatie/Visitor.java +++ b/Applicatie/Visitor.java @@ -362,30 +362,38 @@ public class Visitor } @SuppressWarnings("static-access") - public void fillActions() { + public void fillActions() + { int startTime = 540; int stopTime = 1260; - while (startTime < stopTime) { + while (startTime < stopTime) + { int random = (int) Math.floor(Math.random() * 51); - if (random < 40) { + if (random < 40) + { Point2D position = null; DrawObject targetStage = null; ArrayList posEvents = new ArrayList(); - for (Event e : agenda.getEvents()) { - if (startTime >= e.getStart() && startTime < e.getStop()) { + for (Event e : agenda.getEvents()) + { + if (startTime >= e.getStart() && startTime < e.getStop()) + { posEvents.add(e); } } - if (posEvents.size() != 0) { + if (posEvents.size() != 0) + { int r = (int) Math.floor(Math.random() * posEvents.size()); Event evs = posEvents.get(r); - for (DrawObject d : objects) { - if (d.getFileName().equals("stage")) { + for (DrawObject d : objects) + { + if (d.getFileName().equals("stage")) + { Stage s = (Stage) d; - if (s.getStage().getName() - .equals(evs.getStage().getName())) { + if (s.getStage().getName().equals(evs.getStage().getName())) + { position = s.getPosition(); targetStage = d; } @@ -394,50 +402,58 @@ public class Visitor } int randomtime = (int) (40 + (Math.random() * (60 - 40))); - if (position != null) { + if (position != null) + { Waypoint w = getClosestWaypoint(position); - actions.add(new Action(position, startTime, randomtime, - targetStage, w)); + actions.add(new Action(position, startTime, randomtime, targetStage, w)); } startTime = startTime + randomtime; - } else if (random >= 40 && random < 45) { + } + else if (random >= 40 && random < 45) + { Point2D position = null; DrawObject targetStage = null; ArrayList foodPlaces = new ArrayList(); - for (DrawObject d : objects) { - if (d.getFileName().equals("food")) { + for (DrawObject d : objects) + { + if (d.getFileName().equals("food")) + { foodPlaces.add(d); } } - if (foodPlaces.size() != 0) { + if (foodPlaces.size() != 0) + { int r = (int) Math.floor(Math.random() * foodPlaces.size()); position = foodPlaces.get(r).getPosition(); targetStage = foodPlaces.get(r); Waypoint w = getClosestWaypoint(position); - actions.add(new Action(position, startTime, 35, - targetStage, w)); + actions.add(new Action(position, startTime, 35, targetStage, w)); startTime = startTime + 20; } startTime = startTime + 35; - } else if (random > 45) { + } + else if (random > 45) + { Point2D position = null; DrawObject targetStage = null; ArrayList toilets = new ArrayList(); - for (DrawObject d : objects) { - if (d.getFileName().equals("wc")) { + for (DrawObject d : objects) + { + if (d.getFileName().equals("wc")) + { toilets.add(d); } } - if (toilets.size() != 0) { + if (toilets.size() != 0) + { int r = (int) Math.floor(Math.random() * toilets.size()); position = toilets.get(r).getPosition(); targetStage = toilets.get(r); Waypoint w = getClosestWaypoint(position); - actions.add(new Action(position, startTime, 35, - targetStage, w)); + actions.add(new Action(position, startTime, 35, targetStage, w)); startTime = startTime + 20; } startTime = startTime + 35;