diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index 0b36ab16..80ecac3e 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -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) { diff --git a/src/main/java/seng302/utilities/Sounds.java b/src/main/java/seng302/utilities/Sounds.java index bba19f93..e57810b9 100644 --- a/src/main/java/seng302/utilities/Sounds.java +++ b/src/main/java/seng302/utilities/Sounds.java @@ -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); diff --git a/src/main/java/seng302/visualiser/GameClient.java b/src/main/java/seng302/visualiser/GameClient.java index 501b8347..c6b6ea60 100644 --- a/src/main/java/seng302/visualiser/GameClient.java +++ b/src/main/java/seng302/visualiser/GameClient.java @@ -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 finishedBoats = new ArrayList<>(); + private ObservableList 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(); } diff --git a/src/main/resources/server_config/xml_templates/race.ftlh b/src/main/resources/server_config/xml_templates/race.ftlh index 8fa95216..7c58cb3e 100644 --- a/src/main/resources/server_config/xml_templates/race.ftlh +++ b/src/main/resources/server_config/xml_templates/race.ftlh @@ -35,15 +35,7 @@ - - - - - - - - - + diff --git a/src/main/resources/sounds/Sms-notification.mp3 b/src/main/resources/sounds/Sms-notification.mp3 new file mode 100644 index 00000000..6965d388 Binary files /dev/null and b/src/main/resources/sounds/Sms-notification.mp3 differ