implemented human vote result sounds.
This commit is contained in:
parent
ea2dc03a90
commit
d2ada1d1ae
@ -8,3 +8,4 @@ serai
|
||||
serai
|
||||
Jonas
|
||||
Jonas
|
||||
Jonas
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user