diff --git a/Projekte/battleship/client/src/main/java/pp/battleship/client/GameSound.java b/Projekte/battleship/client/src/main/java/pp/battleship/client/GameSound.java index 0fdcef68..844af57b 100644 --- a/Projekte/battleship/client/src/main/java/pp/battleship/client/GameSound.java +++ b/Projekte/battleship/client/src/main/java/pp/battleship/client/GameSound.java @@ -34,6 +34,7 @@ public class GameSound extends AbstractAppState implements GameEventListener { private AudioNode splashSound; private AudioNode shipDestroyedSound; private AudioNode explosionSound; + private AudioNode missleSound; /** * Checks if sound is enabled in the preferences. @@ -78,6 +79,7 @@ public void initialize(AppStateManager stateManager, Application app) { shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS + missleSound = loadSound(app, "Sound/Effects/missle.wav"); } /** @@ -108,6 +110,14 @@ public void splash() { splashSound.playInstance(); } + /** + * Plays the missle flyby sound effect. + */ + public void flyBy() { + if (isEnabled() && missleSound != null) + missleSound.playInstance(); + } + /** * Plays the explosion sound effect. */ @@ -130,6 +140,7 @@ public void receivedEvent(SoundEvent event) { case EXPLOSION -> explosion(); case SPLASH -> splash(); case DESTROYED_SHIP -> shipDestroyed(); + case MISSLE_FLYBY -> flyBy(); } } } diff --git a/Projekte/battleship/client/src/main/resources/Sound/Effects/missle.wav b/Projekte/battleship/client/src/main/resources/Sound/Effects/missle.wav new file mode 100644 index 00000000..30da79dd Binary files /dev/null and b/Projekte/battleship/client/src/main/resources/Sound/Effects/missle.wav differ diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/game/client/AnimationState.java b/Projekte/battleship/model/src/main/java/pp/battleship/game/client/AnimationState.java index 99143f1e..619563c5 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/game/client/AnimationState.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/game/client/AnimationState.java @@ -33,6 +33,7 @@ public AnimationState(ClientGameLogic logic, boolean myTurn, IntPoint position) logic.getOpponentMap().add(shell); } else { logic.getOwnMap().add(shell); + logic.playSound(Sound.MISSLE_FLYBY); } } diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/notification/Sound.java b/Projekte/battleship/model/src/main/java/pp/battleship/notification/Sound.java index d82ab698..8af58d8d 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/notification/Sound.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/notification/Sound.java @@ -22,5 +22,9 @@ public enum Sound { /** * Sound of a ship being destroyed. */ - DESTROYED_SHIP + DESTROYED_SHIP, + /** + * Sound of an incomming missle. + */ + MISSLE_FLYBY, }