diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java index 98d1d25c2fdec8b4a97fb8261593414df11d7992..356df6dbc19b6352d5d9d45d974c19411b25b868 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java @@ -4,6 +4,8 @@ import de.hdm_stuttgart.battlearena.Controller.GameSceneController; import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; +import de.hdm_stuttgart.battlearena.Model.Sound.SFX; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -26,6 +28,7 @@ public class Bomb implements IEntity { private BoundingBox boxCollider; private final ObjectType OBJECT_TYPE = ObjectType.BOMB; private ObjectStatus OBJECT_STATUS = ObjectStatus.UNUSED; + private SoundEffects soundEffects; public Bomb(int posX, int posY, GraphicsContext graphicsContext) { this.posX = posX; @@ -89,6 +92,7 @@ public class Bomb implements IEntity { frameIndex = 2; } else if (frameIndex == 2) { frameIndex = 3; + soundEffects.playSoundEffectOnce(SFX.BOMB); } else if (frameIndex == 3) { OBJECT_STATUS = ObjectStatus.USED; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java index 07a125c85ae9364a7efe5ed20f29305ffe36b6ed..a3cfbc5cf4ac5d76652719cbc524ad0673f505ac 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java @@ -278,7 +278,6 @@ class Player implements IEntity { private void performEntityCollision(boolean isEntityCollision) { if (isEntityCollision) { - soundEffects.playSoundEffectOnce(SFX.COLLISION); if (playerDirection == EntityDirection.UP) { mapPosY = lastMapPosY + 30; } else if (playerDirection == EntityDirection.DOWN) { @@ -323,6 +322,7 @@ class Player implements IEntity { if (inputHandler.isBomb() && PLAYER_MODE == PlayerMode.PLAYER_ONE || inputHandler.isSdBomb() && PLAYER_MODE == PlayerMode.PLAYER_TWO) { + soundEffects.playSoundEffectOnce(SFX.BOMB_FUSE); int spawnCordX = mapPosX + 12; int spawnCordY = mapPosY + 12; @@ -343,7 +343,8 @@ class Player implements IEntity { TileManager.tileMap[yTile][xTile] = 7; for (int i = 0; i < 3; i++) { isDestructible = checkTileNon_Destructible(yTile + 1 + i, xTile); //If Tile solid , -> should stop comparing, - if (isDestructible && (yTile < 18 && xTile < 18)) { //because for now, Tile behind gets destroyed aswell + if (isDestructible && (yTile < 18 && xTile < 18)) {//because for now, Tile behind gets destroyed aswell + soundEffects.playSoundEffectOnce(SFX.WOOD_Destruction); TileManager.tileMap[yTile + 1 + i][xTile] = 8; /*if(entity || entity2) { entity2.gotHit(2); //See if enemy or player hit @@ -351,16 +352,19 @@ class Player implements IEntity { } isDestructible = checkTileNon_Destructible(yTile - 1 - i, xTile); if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + soundEffects.playSoundEffectOnce(SFX.WOOD_Destruction); TileManager.tileMap[yTile - 1 - i][xTile] = 8; entity.gotHit(2); } isDestructible = checkTileNon_Destructible(yTile, xTile + 1 + i); if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + soundEffects.playSoundEffectOnce(SFX.WOOD_Destruction); TileManager.tileMap[yTile][xTile + 1 + i] = 8; entity.gotHit(2); } isDestructible = checkTileNon_Destructible(yTile, xTile - 1 - i); if (isDestructible && (yTile < 18 && xTile < 18 && yTile > 0 && xTile > 0)) { + soundEffects.playSoundEffectOnce(SFX.WOOD_Destruction); TileManager.tileMap[yTile][xTile - 1 - i] = 8; entity.gotHit(2); } @@ -410,7 +414,7 @@ class Player implements IEntity { if (inputHandler.isAttack() && PLAYER_MODE == PlayerMode.PLAYER_ONE || inputHandler.isSdAttack() && PLAYER_MODE == PlayerMode.PLAYER_TWO) { - soundEffects.playSoundEffectOnce(SFX.SWORD_HIT); + soundEffects.playSoundEffectOnce(SFX.SWORD_SWING); if (playerDirection == EntityDirection.UP) { hitBox = new BoundingBox(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); graphicsContext.strokeRect(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); @@ -441,6 +445,7 @@ class Player implements IEntity { private void hitEnemy(IEntity entity, GraphicsContext graphicsContext, BoundingBox hitBox, double dropChance, double randomDropChance) { if (hitBox.intersects(entity.getBoxCollider())) { + soundEffects.playSoundEffectOnce(SFX.SWORD_HIT); entity.gotHit(damage); log.info("Hit enemy"); @@ -520,7 +525,6 @@ class Player implements IEntity { @Override public void gotHit(int damageDone) { health -= damageDone; - //soundEffects.playSoundEffectOnce(); } @Override diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java index a90491b35e0c57d88eb3e7ae6ed85f6df20a4b32..ee20850cec83231a350297f7b7af386ed6b71f8f 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java @@ -47,7 +47,7 @@ public class MusicPlayer{ GameState newGameState = RuntimeInfo.getInstance().getGameState(); if(currentGameState != newGameState){ currentGameState = newGameState; - Platform.runLater(this::updateMusic); + updateMusic(); } },0,1, TimeUnit.SECONDS); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java index 15b09e21a3fd921ad6ca01e4673cdfcf5089679a..44333225a779646defdd9c70111f806e8c399492 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java @@ -1,18 +1,31 @@ package de.hdm_stuttgart.battlearena.Model.Sound; public enum SFX { - BOOM("src/main/resources/sound/sfx/otSFX/explosion.mp3"), + //Poweup Sounds POWERUP("src/main/resources/sound/sfx/otSFX/powerup.mp3"), - COIN_COLLECTED("src/main/resources/sound/sfx/otSFX/drop-coins.mp3"), - SWORD_HIT("src/main/resources/sound/sfx/otSFX/sword-hit.mp3"), - COLLISION("src/main/resources/sound/sfx/otSFX/body-falling-to-ground.mp3"); + COIN_COLLECTED("src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3"), + + //Bomb + BOMB_FUSE("src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav"), + BOMB("src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav"), + + //Attack Sounds + SWORD_HIT("src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav"), + SWORD_SWING("src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav"), + + //Destruction Sounds + WOOD_Destruction("src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav"), + + //Die Sounds + DEAD("src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3"); private String path; - SFX(String path){ + + SFX(String path) { this.path = path; } - public String getPath(){ + public String getPath() { return path; } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java index cd16b2fa69369ea2c80408de115a6f6d1ac4655a..630b50997f4102d08e0f1f6abb5821f10f4a1f0b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java @@ -78,7 +78,7 @@ public class SoundEffects { Thread sfx = new Thread(()->{ AudioClip audioClip = new AudioClip(getClass().getResource(resource).toExternalForm()); audioClip.play(); - audioClip.setVolume((double) Persistence.getInstance().getSettings().getSfxVolume() /100); + audioClip.setVolume((double) Persistence.getInstance().getSettings().getSfxVolume()/100); }); sfx.setDaemon(true); sfx.start(); diff --git a/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav b/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav new file mode 100644 index 0000000000000000000000000000000000000000..8ed31a9c367d3a0dc74d7ac28d5373bdf4b4f420 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav b/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav new file mode 100644 index 0000000000000000000000000000000000000000..b1c6c91018821fa54644db465b380e99974d6e8a Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav b/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav new file mode 100644 index 0000000000000000000000000000000000000000..6056057b4e42ca6e9b87dfabafc009896ab0c83e Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav b/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav new file mode 100644 index 0000000000000000000000000000000000000000..31099639db4593beed4764193084bdf3fbc36aa0 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav b/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav new file mode 100644 index 0000000000000000000000000000000000000000..e51acbdb37fb2bea31b35251facd10643caa18e7 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/body-falling-to-ground.mp3 b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 similarity index 100% rename from src/main/resources/sound/sfx/otSFX/body-falling-to-ground.mp3 rename to src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 diff --git a/src/main/resources/sound/sfx/otSFX/explosion.mp3 b/src/main/resources/sound/sfx/otSFX/explosion.mp3 deleted file mode 100644 index f17a59c480ca97ee47e5bfb15141999d72c0a8d6..0000000000000000000000000000000000000000 Binary files a/src/main/resources/sound/sfx/otSFX/explosion.mp3 and /dev/null differ diff --git a/src/main/resources/sound/sfx/otSFX/drop-coins.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 similarity index 100% rename from src/main/resources/sound/sfx/otSFX/drop-coins.mp3 rename to src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 diff --git a/src/main/resources/sound/sfx/otSFX/powerup.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 similarity index 100% rename from src/main/resources/sound/sfx/otSFX/powerup.mp3 rename to src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 diff --git a/src/main/resources/sound/sfx/otSFX/sword-hit.mp3 b/src/main/resources/sound/sfx/otSFX/sword-hit.mp3 deleted file mode 100644 index 1a63129f0e675c128e2dc7f3864d3cb9b48f565e..0000000000000000000000000000000000000000 Binary files a/src/main/resources/sound/sfx/otSFX/sword-hit.mp3 and /dev/null differ