|
|
|
@ -18,6 +18,7 @@ import javafx.scene.input.KeyEvent;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
|
|
|
|
|
import javafx.scene.media.AudioClip;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
@ -66,6 +67,9 @@ public class RaceViewController extends Controller {
|
|
|
|
private ObservableList<Subject3D> viewSubjects;
|
|
|
|
private ObservableList<Subject3D> viewSubjects;
|
|
|
|
private ResizableRaceCanvas raceCanvas;
|
|
|
|
private ResizableRaceCanvas raceCanvas;
|
|
|
|
private boolean mapToggle = true;
|
|
|
|
private boolean mapToggle = true;
|
|
|
|
|
|
|
|
private int heartbeatDelay = 1000;
|
|
|
|
|
|
|
|
private long heartbeatTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Arrow pointing to next mark in third person
|
|
|
|
* Arrow pointing to next mark in third person
|
|
|
|
@ -115,6 +119,7 @@ public class RaceViewController extends Controller {
|
|
|
|
initKeypressHandler();
|
|
|
|
initKeypressHandler();
|
|
|
|
initialiseRaceVisuals();
|
|
|
|
initialiseRaceVisuals();
|
|
|
|
initialiseRaceCanvas();
|
|
|
|
initialiseRaceCanvas();
|
|
|
|
|
|
|
|
healthLoop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -656,6 +661,34 @@ public class RaceViewController extends Controller {
|
|
|
|
}.start();
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void healthLoop(){
|
|
|
|
|
|
|
|
new AnimationTimer(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long arg0){
|
|
|
|
|
|
|
|
if (raceState.getRaceStatusEnum() == RaceStatusEnum.FINISHED) {
|
|
|
|
|
|
|
|
stop(); // stop the timer
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=20){
|
|
|
|
|
|
|
|
heartbeatDelay = 500;
|
|
|
|
|
|
|
|
} else if (raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=40){
|
|
|
|
|
|
|
|
heartbeatDelay = 1000;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=40){
|
|
|
|
|
|
|
|
if(System.currentTimeMillis() > heartbeatTime+heartbeatDelay) {
|
|
|
|
|
|
|
|
AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/heartbeat.mp3").toExternalForm());
|
|
|
|
|
|
|
|
sound.play();
|
|
|
|
|
|
|
|
heartbeatTime = System.currentTimeMillis() + heartbeatDelay;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* toggles if the info table is shown
|
|
|
|
* toggles if the info table is shown
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|