implemented race finish functionality, finish screen not loading properly yet #story[1124]

This commit is contained in:
Peter Galloway
2017-08-15 20:48:51 +12:00
parent 23a04facbe
commit 50baf6f85b
3 changed files with 23 additions and 2 deletions
@@ -70,6 +70,7 @@ public class ClientYacht extends Observable {
this.location = new GeoPoint(57.670341, 11.826856); this.location = new GeoPoint(57.670341, 11.826856);
this.heading = 120.0; //In degrees this.heading = 120.0; //In degrees
this.currentVelocity = 0d; this.currentVelocity = 0d;
this.boatStatus = 1;
} }
/** /**
@@ -155,6 +155,17 @@ public class GameClient {
raceView.loadRace(allBoatsMap, courseData, raceState, player); raceView.loadRace(allBoatsMap, courseData, raceState, player);
} }
private void loadFinishScreenView() {
FXMLLoader fxmlLoader = new FXMLLoader(
getClass().getResource("/views/FinishScreenView.fxml"));
try {
holderPane.getChildren().clear();
holderPane.getChildren().add(fxmlLoader.load());
} catch (IOException e) {
e.printStackTrace();
}
}
private void parsePackets() { private void parsePackets() {
while (socketThread.getPacketQueue().peek() != null) { while (socketThread.getPacketQueue().peek() != null) {
StreamPacket packet = socketThread.getPacketQueue().poll(); StreamPacket packet = socketThread.getPacketQueue().poll();
@@ -257,6 +268,17 @@ public class GameClient {
private void processRaceStatusUpdate(RaceStatusData data) { private void processRaceStatusUpdate(RaceStatusData data) {
if (allXMLReceived()) { if (allXMLReceived()) {
raceState.updateState(data); raceState.updateState(data);
boolean raceFinished = true;
for (ClientYacht yacht : allBoatsMap.values()) {
if (yacht.getBoatStatus() != 3) {
raceFinished = false;
}
}
if (raceFinished == true) {
loadFinishScreenView();
}
for (long[] boatData : data.getBoatData()) { for (long[] boatData : data.getBoatData()) {
ClientYacht clientYacht = allBoatsMap.get((int) boatData[0]); ClientYacht clientYacht = allBoatsMap.get((int) boatData[0]);
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]); clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
@@ -79,7 +79,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
private GameView gameView; private GameView gameView;
private RaceState raceState; private RaceState raceState;
private Timeline timerTimeline;
private Timer timer = new Timer(); private Timer timer = new Timer();
private List<Series<String, Double>> sparkLineData = new ArrayList<>(); private List<Series<String, Double>> sparkLineData = new ArrayList<>();
private ImportantAnnotationsState importantAnnotations; private ImportantAnnotationsState importantAnnotations;
@@ -396,7 +395,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
textToAdd.setStyle(""); textToAdd.setStyle("");
vboxEntries.add(textToAdd); vboxEntries.add(textToAdd);
} }
// System.out.println("finished a loop :))))))))))))");
} }
Platform.runLater(() -> Platform.runLater(() ->
positionVbox.getChildren().setAll(vboxEntries) positionVbox.getChildren().setAll(vboxEntries)