Added visual display when boat dies. Added sound when boat dies. #story[1311]
This commit is contained in:
@@ -698,7 +698,13 @@ public class RaceViewController extends Controller {
|
|||||||
} else {
|
} else {
|
||||||
for(VisualiserBoat boat : raceState.getBoats()){
|
for(VisualiserBoat boat : raceState.getBoats()){
|
||||||
for (HealthEffect fp : healthEffectList){
|
for (HealthEffect fp : healthEffectList){
|
||||||
|
|
||||||
if(fp.getSourceID()==boat.getSourceID()){
|
if(fp.getSourceID()==boat.getSourceID()){
|
||||||
|
if(boat.getHealth()<=0){
|
||||||
|
fp.displayDeath();
|
||||||
|
fp.setSourceID(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
if(boat.getHealth()<=10){
|
if(boat.getHealth()<=10){
|
||||||
fp.flash(System.currentTimeMillis(), 300, boat.getSourceID()==raceState.getPlayerBoatID());
|
fp.flash(System.currentTimeMillis(), 300, boat.getSourceID()==raceState.getPlayerBoatID());
|
||||||
}
|
}
|
||||||
@@ -713,25 +719,6 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// try {
|
|
||||||
// if(raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=10){
|
|
||||||
// heartbeatDelay = 300;
|
|
||||||
// } else if (raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=20){
|
|
||||||
// heartbeatDelay = 500;
|
|
||||||
// }
|
|
||||||
// if(raceState.getBoat(raceState.getPlayerBoatID()).getHealth()<=20){
|
|
||||||
//
|
|
||||||
// //imageView.translateXProperty().setValue(raceState.getBoat(raceState.getPlayerBoatID()).getPosition().getLongitude());
|
|
||||||
// if(System.currentTimeMillis() > heartbeatTime+heartbeatDelay) {
|
|
||||||
// AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/warning.mp3").toExternalForm());
|
|
||||||
// sound.setVolume(0.3);
|
|
||||||
// sound.play();
|
|
||||||
// heartbeatTime = System.currentTimeMillis() + heartbeatDelay;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (BoatNotFoundException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class HealthEffect extends Subject3D {
|
|||||||
private int sourceID;
|
private int sourceID;
|
||||||
private long currentTime;
|
private long currentTime;
|
||||||
private long flashInterval;
|
private long flashInterval;
|
||||||
private AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/warning.mp3").toExternalForm());
|
private AudioClip warningSound = new AudioClip(this.getClass().getResource("/visualiser/sounds/warning.mp3").toExternalForm());
|
||||||
|
private AudioClip deadSound = new AudioClip(this.getClass().getResource("/visualiser/sounds/dead1.wav").toExternalForm());
|
||||||
|
|
||||||
public HealthEffect(int sourceID, long currentTime){
|
public HealthEffect(int sourceID, long currentTime){
|
||||||
super(createEffect(), 0);
|
super(createEffect(), 0);
|
||||||
@@ -66,6 +67,21 @@ public class HealthEffect extends Subject3D {
|
|||||||
return sourceID;
|
return sourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSourceID(int id){
|
||||||
|
this.sourceID = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayDeath(){
|
||||||
|
Image image = new Image(HealthEffect.class.getClassLoader().getResourceAsStream("images/warning2.png"));
|
||||||
|
PhongMaterial material = (PhongMaterial) this.getMesh().getMaterial();
|
||||||
|
material.setDiffuseColor(Color.web("#FFFFFF"));
|
||||||
|
material.setSpecularColor(Color.web("#000000"));
|
||||||
|
material.setDiffuseMap(image);
|
||||||
|
this.getMesh().setMaterial(material);
|
||||||
|
deadSound.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flash the mesh view at a certain interval
|
* Flash the mesh view at a certain interval
|
||||||
* @param checkTime The current time of flash
|
* @param checkTime The current time of flash
|
||||||
@@ -78,8 +94,8 @@ public class HealthEffect extends Subject3D {
|
|||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
if(playerBoat) {
|
if(playerBoat) {
|
||||||
sound.setVolume(0.1);
|
warningSound.setVolume(0.1);
|
||||||
sound.play();
|
warningSound.play();
|
||||||
}
|
}
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
Reference in New Issue
Block a user