diff --git a/OgGhostWinners.txt b/OgGhostWinners.txt index ce0952f..323edb5 100644 --- a/OgGhostWinners.txt +++ b/OgGhostWinners.txt @@ -8,3 +8,4 @@ serai serai Jonas Jonas +Jonas diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java index d6a35ca..a4b95c7 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java @@ -4,6 +4,7 @@ import ch.unibas.dmi.dbis.cs108.BudaLogConfig; import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger; import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters; import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol; +import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -171,6 +172,14 @@ public class VoteHandler { passenger.send( ClientGameInfoHandler.humansVotedFor + voteIndex + ClientGameInfoHandler.isAHuman, game); } + + for (ClientHandler c: game.getLobby().getLobbyClients()) { //send human vote sound to clients + c.sendMsgToClient(Protocol.playSound + "$" + "HV"); + } + } else if (!passengers[voteIndex].getIsOG()) { + for (ClientHandler c: game.getLobby().getLobbyClients()) { //send ghost vote sound to clients + c.sendMsgToClient(Protocol.playSound + "$" + "GV"); + } } if (passengers[voteIndex].getIsGhost()) { // if player is a ghost diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/Sound.java b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/Sound.java index 59e62f8..15da20a 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/Sound.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/Sound.java @@ -122,17 +122,27 @@ public class Sound { } public static void gameoverghosts() { - stopmusicday(); - gameoverghosts.play(defaultvolume); } + waitForABitThenEndDayMusic(); + voteforghost.stop(); + voteforhuman.stop(); + gameoverghosts.play(defaultvolume - 0.3); } public static void gameoverhumans() { - stopmusicday(); - gameoverhumans.play(defaultvolume); + waitForABitThenEndDayMusic(); + voteforghost.stop(); + voteforhuman.stop(); + gameoverhumans.play(defaultvolume - 0.1); } - public static void voteforghost() { voteforghost.play(defaultvolume); } + public static void voteforghost() { + waitForABitThenEndDayMusic(); + voteforghost.play(defaultvolume - 0.4); + } - public static void voteforhuman() { voteforhuman.play(defaultvolume); } + public static void voteforhuman() { + waitForABitThenEndDayMusic(); + voteforhuman.play(defaultvolume - 0.2); + } public static void musicday() { musicday.play(defaultvolume); @@ -193,6 +203,23 @@ public class Sound { ghost.play(0.08, 0.0, playbackspeed, 0.0, 5); } + /** + * waits for a bit, then ends day music. :) + */ + public static void waitForABitThenEndDayMusic() { + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(1820); + //the time it takes for the vote result sound to ramp up, so the music ends exactly on the "big reveal" + } catch (InterruptedException e) { + e.printStackTrace(); + } + stopmusicday(); + } + }).start(); + } }