mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
[WIP] Adding player position, boat speed, boat heading
#story[1245]
This commit is contained in:
@@ -253,7 +253,7 @@ public class ClientYacht extends Observable {
|
||||
public void updateLocation(double lat, double lng, double heading, double velocity) {
|
||||
setLocation(lat, lng);
|
||||
this.heading = heading;
|
||||
// this.currentVelocity = velocity;
|
||||
this.currentVelocity = velocity;
|
||||
updateVelocityProperty(velocity);
|
||||
for (YachtLocationListener yll : locationListeners) {
|
||||
yll.notifyLocation(this, lat, lng, heading, sailIn, velocity);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class GameView3D {
|
||||
System.out.println(camera.getTranslateY());
|
||||
System.out.println(camera.getTranslateZ());
|
||||
camera.setTranslateZ(-80);
|
||||
camera.setTranslateY(150);
|
||||
camera.setTranslateY(170);
|
||||
Sphere red = new Sphere(1);
|
||||
red.setMaterial(new PhongMaterial(Color.RED));
|
||||
red.setLayoutX(0);
|
||||
|
||||
@@ -103,6 +103,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
private Label windDirectionLabel;
|
||||
@FXML
|
||||
private Label windSpeedLabel;
|
||||
@FXML
|
||||
private Label positionLabel, boatSpeedLabel, boatHeadingLabel;
|
||||
|
||||
//Race Data
|
||||
private Map<Integer, ClientYacht> participants;
|
||||
@@ -119,6 +121,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
private ImportantAnnotationsState importantAnnotations;
|
||||
private Polyline windArrow = new WindArrow(Color.LIGHTGRAY);
|
||||
private ObservableList<ClientYacht> selectionComboBoxList = FXCollections.observableArrayList();
|
||||
private ClientYacht player;
|
||||
|
||||
public void initialize() {
|
||||
Sounds.stopMusic();
|
||||
@@ -181,6 +184,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
this.courseData = raceData;
|
||||
this.markers = raceData.getCompoundMarks();
|
||||
this.raceState = raceState;
|
||||
this.player = player;
|
||||
|
||||
raceState.getPlayerPositions().addListener((ListChangeListener<ClientYacht>) c -> {
|
||||
while (c.next()) {
|
||||
@@ -434,6 +438,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Platform.runLater(() -> updatePosition());
|
||||
Platform.runLater(() -> updateBoatSpeed());
|
||||
Platform.runLater(() -> updateBoatHeading());
|
||||
Platform.runLater(() -> updateRaceTime());
|
||||
}
|
||||
}, 0, 1000);
|
||||
@@ -497,6 +504,43 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePosition() {
|
||||
if (player.getPosition() == null) {
|
||||
positionLabel.setText("Position:\n0");
|
||||
} else {
|
||||
switch (player.getPosition()) {
|
||||
case 1:
|
||||
positionLabel.setText("Position:\n1st");
|
||||
break;
|
||||
case 2:
|
||||
positionLabel.setText("Position:\n2nd");
|
||||
break;
|
||||
case 3:
|
||||
positionLabel.setText("Position:\n3rd");
|
||||
break;
|
||||
case 21:
|
||||
positionLabel.setText("Position:\n21st");
|
||||
break;
|
||||
case 22:
|
||||
positionLabel.setText("Position:\n22nd");
|
||||
break;
|
||||
case 23:
|
||||
positionLabel.setText("Position:\n23rd");
|
||||
break;
|
||||
default:
|
||||
positionLabel.setText("Position:\n" + player.getPosition() + "th");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBoatSpeed() {
|
||||
boatSpeedLabel.setText("Boat Speed:\n" + String.valueOf(player.getVelocityProperty().toString()));
|
||||
}
|
||||
|
||||
private void updateBoatHeading() {
|
||||
boatHeadingLabel.setText("Boat Heading:\n" + String.valueOf(player.getHeading()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the order of the yachts as from the StreamParser and sets them in the yacht order
|
||||
* section
|
||||
|
||||
Reference in New Issue
Block a user