Added finish noise.

#story[1249]
This commit is contained in:
Kusal Ekanayake
2017-09-05 13:44:14 +12:00
parent 6ee2517f74
commit 396098e009
5 changed files with 24 additions and 10 deletions
@@ -366,7 +366,7 @@ public class GameState implements Runnable {
Double velocity = yacht.getCurrentVelocity();
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots);
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * 5;
// TODO: 15/08/17 remove magic numbers from these equations.
if (yacht.getSailIn()) {
if (velocity < maxBoatSpeed - 500) {
@@ -22,6 +22,10 @@ public class Sounds {
musicPlayer.stop();
}
public static void stopSoundEffects() {
soundEffect.stop();
}
public static void toggleMuteMusic() {
musicMuted = !musicMuted;
musicPlayer.setMute(musicMuted);
@@ -75,6 +79,13 @@ public class Sounds {
soundPlayer.setMute(soundEffectsMuted);
}
public static void playFinishSound() {
Media finishSound = new Media(Sounds.class.getClassLoader().getResource("sounds/Sms-notification.mp3").toString());
soundPlayer = new MediaPlayer(finishSound);
soundPlayer.play();
soundPlayer.setMute(soundEffectsMuted);
}
public static void playCapGunSound() {
Media gunSound = new Media(Sounds.class.getClassLoader().getResource("sounds/Gunshot-sound.mp3").toString());
soundPlayer = new MediaPlayer(gunSound);
@@ -3,6 +3,7 @@ package seng302.visualiser;
import java.io.IOException;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Map;
import java.util.TimeZone;
import javafx.application.Platform;
@@ -54,6 +55,8 @@ public class GameClient {
private RaceState raceState = new RaceState();
private LobbyController lobbyController;
private ArrayList<ClientYacht> finishedBoats = new ArrayList<>();
private ObservableList<String> clientLobbyList = FXCollections.observableArrayList();
/**
@@ -160,6 +163,10 @@ public class GameClient {
// server.terminate();
// server = null;
// }
Sounds.stopSoundEffects();
Sounds.stopMusic();
Sounds.playMenuMusic();
FXMLLoader fxmlLoader = new FXMLLoader(
getClass().getResource("/views/StartScreenView.fxml"));
try {
@@ -348,6 +355,9 @@ public class GameClient {
for (ClientYacht yacht : allBoatsMap.values()) {
if (yacht.getBoatStatus() != BoatStatus.FINISHED.getCode()) {
raceFinished = false;
} else if (!finishedBoats.contains(yacht)) {
finishedBoats.add(yacht);
Sounds.playFinishSound();
}
}
@@ -363,6 +373,7 @@ public class GameClient {
}
if (raceFinished) {
Sounds.playFinishSound();
close();
loadFinishScreenView();
}
@@ -35,15 +35,7 @@
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="PS" ZoneSize="3" />
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="5" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="6" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="7" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="8" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="9" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="10" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="11" CompoundMarkID="5" Rounding="PS" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="5" Rounding="PS" ZoneSize="3" />
</CompoundMarkSequence>
<CourseLimit>
<Limit SeqID="1" Lat="57.6739450" Lon="11.8417100" />
Binary file not shown.