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 0fdcef6..22e6b0b 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 shellFlyingSound; /** * Checks if sound is enabled in the preferences. @@ -78,6 +79,7 @@ public class GameSound extends AbstractAppState implements GameEventListener { 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 + shellFlyingSound = loadSound(app, "Sound/Effects/shell_flying.wav"); } /** @@ -124,12 +126,27 @@ public class GameSound extends AbstractAppState implements GameEventListener { shipDestroyedSound.playInstance(); } + /** + * Plays the shell flying sound effect. + */ + public void shellFly() { + if (isEnabled() && shellFlyingSound != null) { + shellFlyingSound.playInstance(); + } + } + + /** + * Handles a recieved {@code SoundEvent} and plays the according sound. + * + * @param event the Sound event to be processed + */ @Override public void receivedEvent(SoundEvent event) { switch (event.sound()) { case EXPLOSION -> explosion(); case SPLASH -> splash(); case DESTROYED_SHIP -> shipDestroyed(); + case SHELL_FLYING -> shellFly(); } } } diff --git a/Projekte/battleship/client/src/main/resources/Sound/Effects/shell_flying.wav b/Projekte/battleship/client/src/main/resources/Sound/Effects/shell_flying.wav new file mode 100644 index 0000000..35bcb09 Binary files /dev/null and b/Projekte/battleship/client/src/main/resources/Sound/Effects/shell_flying.wav differ