|
|
|
@ -2,12 +2,9 @@ package seng302.Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.application.Platform;
|
|
|
|
import javafx.application.Platform;
|
|
|
|
import javafx.beans.property.StringProperty;
|
|
|
|
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.ObservableArray;
|
|
|
|
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import seng302.Controllers.RaceController;
|
|
|
|
import seng302.Controllers.RaceController;
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,8 +19,8 @@ public abstract class Race implements Runnable {
|
|
|
|
protected RaceController controller;
|
|
|
|
protected RaceController controller;
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected int scale_factor = 15;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected int scaleFactor = 1;
|
|
|
|
|
|
|
|
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
|
|
|
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
|
|
|
@ -36,7 +33,7 @@ public abstract class Race implements Runnable {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Race(BoatInRace[] boats, ArrayList<Leg> legs, RaceController controller) {
|
|
|
|
public Race(BoatInRace[] boats, ArrayList<Leg> legs, RaceController controller) {
|
|
|
|
for (BoatInRace boat : boats) {
|
|
|
|
for (BoatInRace boat : boats) {
|
|
|
|
boat.setScaledVelocity(boat.getVelocity() * scale_factor);
|
|
|
|
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(boats);
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(boats);
|
|
|
|
@ -54,6 +51,22 @@ public abstract class Race implements Runnable {
|
|
|
|
this(boats, marks, null);
|
|
|
|
this(boats, marks, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Race(BoatInRace[] boats, ArrayList<Leg> legs, int scaleFactor) {
|
|
|
|
|
|
|
|
for (BoatInRace boat : boats) {
|
|
|
|
|
|
|
|
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(boats);
|
|
|
|
|
|
|
|
this.legs = legs;
|
|
|
|
|
|
|
|
this.legs.add(new Leg("Finish", this.legs.size()));
|
|
|
|
|
|
|
|
this.scaleFactor = scaleFactor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setScaleFactor(int scaleFactor) {
|
|
|
|
|
|
|
|
this.scaleFactor = scaleFactor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Runnable for the thread.
|
|
|
|
* Runnable for the thread.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -122,7 +135,7 @@ public abstract class Race implements Runnable {
|
|
|
|
long hours;
|
|
|
|
long hours;
|
|
|
|
|
|
|
|
|
|
|
|
currentTimeInSeconds = totalTimeElapsed / 1000;
|
|
|
|
currentTimeInSeconds = totalTimeElapsed / 1000;
|
|
|
|
long scaledTimeInSeconds = currentTimeInSeconds * scale_factor;
|
|
|
|
long scaledTimeInSeconds = currentTimeInSeconds * scaleFactor;
|
|
|
|
minutes = scaledTimeInSeconds / 60;
|
|
|
|
minutes = scaledTimeInSeconds / 60;
|
|
|
|
remainingSeconds = scaledTimeInSeconds % 60;
|
|
|
|
remainingSeconds = scaledTimeInSeconds % 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
|