Bells only start during the day, also ghosts now make noises as originally intended
This commit is contained in:
parent
977f126073
commit
7a81987316
@ -363,3 +363,6 @@ Habe Highscore und Players in Lobbies auf die einfachst mögliche Art mit Textfl
|
|||||||
- Seraina: Animation von in-game-Hintergrund, GUI
|
- Seraina: Animation von in-game-Hintergrund, GUI
|
||||||
- Jonas: Sound design
|
- Jonas: Sound design
|
||||||
- Alex: Vorbereitung für Programmierung von unit tests mit Mockito
|
- Alex: Vorbereitung für Programmierung von unit tests mit Mockito
|
||||||
|
|
||||||
|
16.5.2022 - Jonas
|
||||||
|
Have been working on implementing all sound effects over the last couple of days
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||||
|
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all communication Client to Server concerning gamestate updates i.e. client a has voted
|
* Handles all communication Client to Server concerning gamestate updates i.e. client a has voted
|
||||||
* Maybe unnecessary, everything that is needed might already be implemented in ClientHandler.
|
* Maybe unnecessary, everything that is needed might already be implemented in ClientHandler.
|
||||||
@ -16,7 +18,7 @@ public class ClientGameInfoHandler {
|
|||||||
//relevant for game logic:
|
//relevant for game logic:
|
||||||
public static final String ghostVoteRequest = "Vote on who to ghostify!";
|
public static final String ghostVoteRequest = "Vote on who to ghostify!";
|
||||||
public static final String humanVoteRequest = "Vote for a ghost to kick off!";
|
public static final String humanVoteRequest = "Vote for a ghost to kick off!";
|
||||||
public static final String noiseNotification = "Someone passed by you ";
|
public static final String noiseNotification = Protocol.noiseNotificationProtocol;
|
||||||
public static final String gameOverHumansWin = "Game over, humans win!";
|
public static final String gameOverHumansWin = "Game over, humans win!";
|
||||||
public static final String gameOverGhostsWin = "Game over, ghosts win!";
|
public static final String gameOverGhostsWin = "Game over, ghosts win!";
|
||||||
|
|
||||||
|
|||||||
@ -120,6 +120,8 @@ public class ServerGameInfoHandler {
|
|||||||
case ClientGameInfoHandler.noiseNotification + 3 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 3 + " time(s)":
|
||||||
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
|
||||||
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
||||||
|
case ClientGameInfoHandler.noiseNotification:
|
||||||
|
//todo: jonas: handle bell behaviour correctly.
|
||||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
||||||
//TODO: add likelyhood
|
//TODO: add likelyhood
|
||||||
if(!npc.getKickedOff()) {
|
if(!npc.getKickedOff()) {
|
||||||
@ -148,6 +150,8 @@ public class ServerGameInfoHandler {
|
|||||||
case ClientGameInfoHandler.noiseNotification + 3 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 3 + " time(s)":
|
||||||
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
|
||||||
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
||||||
|
case ClientGameInfoHandler.noiseNotification: //new case where times are not noted.
|
||||||
|
//todo: jonas: handle bell behaviour correctly.
|
||||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
||||||
if(!npc.getKickedOff()) {
|
if(!npc.getKickedOff()) {
|
||||||
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class Timer {
|
|||||||
* The length of time in seconds after the ghost vote during which the ghosts visually walk to /
|
* The length of time in seconds after the ghost vote during which the ghosts visually walk to /
|
||||||
* from their victim and the timespan within which humans will hear a noise. After this, the day starts.
|
* from their victim and the timespan within which humans will hear a noise. After this, the day starts.
|
||||||
*/
|
*/
|
||||||
public static final int ghostAfterVoteTime = 4;
|
public static final int ghostAfterVoteTime = 6;
|
||||||
/**
|
/**
|
||||||
* The maximum length of the human vote in the day, in seconds
|
* The maximum length of the human vote in the day, in seconds
|
||||||
*/
|
*/
|
||||||
@ -85,6 +85,14 @@ public class Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void humanAfterVoteTimer() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(humanAfterVoteTime *1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
LOGGER.warn("Thread " + Thread.currentThread() + " was interrupted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if all ghosts in the game have already voted, returns true if so
|
* Checks if all ghosts in the game have already voted, returns true if so
|
||||||
* @param game the Game the ghosts live in
|
* @param game the Game the ghosts live in
|
||||||
|
|||||||
@ -95,7 +95,8 @@ public class VoteHandler {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < passengers.length; i++) {
|
for (int i = 0; i < passengers.length; i++) {
|
||||||
if (noiseAmount[i] != 0) { // someone walked by this player
|
if (noiseAmount[i] != 0) { // someone walked by this player
|
||||||
passengers[i].send(ClientGameInfoHandler.noiseNotification + noiseAmount[i] + " time(s)", game);
|
//passengers[i].send(ClientGameInfoHandler.noiseNotification + noiseAmount[i] + " time(s)", game); old version, might be useful
|
||||||
|
passengers[i].send(ClientGameInfoHandler.noiseNotification, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ public class VoteHandler {
|
|||||||
ClientGameInfoHandler.humansVotedFor + voteIndex + ClientGameInfoHandler.isAHuman, game);
|
ClientGameInfoHandler.humansVotedFor + voteIndex + ClientGameInfoHandler.isAHuman, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer.ghostAfterVoteTimer();
|
Timer.humanAfterVoteTimer();
|
||||||
if (passengers[voteIndex].getIsGhost()) { // if player is a ghost
|
if (passengers[voteIndex].getIsGhost()) { // if player is a ghost
|
||||||
if (passengers[voteIndex].getIsOG()) { // if ghost is OG --> end game, humans win
|
if (passengers[voteIndex].getIsOG()) { // if ghost is OG --> end game, humans win
|
||||||
System.out.println(ClientGameInfoHandler.gameOverHumansWin);
|
System.out.println(ClientGameInfoHandler.gameOverHumansWin);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class HumanNPC extends Human {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a msg to the ServerGameInfoHandler.humanNpcParser to decide what has to happen now, if
|
* Sends a msg to the ServerGameInfoHandler.humanNpcParser to decide what has to happen now, if
|
||||||
* the npc hasn't been kicked off 8(should never happen to a human though)
|
* the npc hasn't been kicked off (should never happen to a human though)
|
||||||
*
|
*
|
||||||
* @param msg the message that is sent to this player.
|
* @param msg the message that is sent to this player.
|
||||||
* @param game the game the HumanNPC lives on (in game.gameState.passengerTrain)
|
* @param game the game the HumanNPC lives on (in game.gameState.passengerTrain)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||||
|
|
||||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.gamelogic.ClientGameInfoHandler;
|
||||||
import ch.unibas.dmi.dbis.cs108.gamelogic.ClientVoteData;
|
import ch.unibas.dmi.dbis.cs108.gamelogic.ClientVoteData;
|
||||||
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
|
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
|
||||||
import ch.unibas.dmi.dbis.cs108.gamelogic.ServerGameInfoHandler;
|
import ch.unibas.dmi.dbis.cs108.gamelogic.ServerGameInfoHandler;
|
||||||
@ -47,6 +48,8 @@ public class HumanPlayer extends Human {
|
|||||||
String formattedMsg;
|
String formattedMsg;
|
||||||
if (msg.equals(GuiParameters.updateGameState)) {
|
if (msg.equals(GuiParameters.updateGameState)) {
|
||||||
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().humanToString();
|
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().humanToString();
|
||||||
|
} else if (msg.equals(ClientGameInfoHandler.noiseNotification)) {
|
||||||
|
formattedMsg = Protocol.noiseNotificationProtocol;
|
||||||
} else {
|
} else {
|
||||||
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,9 @@ public class JClientProtocolParser {
|
|||||||
LOGGER.warn(msg.substring(6));
|
LOGGER.warn(msg.substring(6));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Protocol.noiseNotificationProtocol:
|
||||||
|
Sound.ghost();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Received unknown command: " + msg);
|
System.out.println("Received unknown command: " + msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public class Sound {
|
|||||||
ghost = ghost04;
|
ghost = ghost04;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ghost.play(defaultvolume, 0.0, playbackspeed, 0.0, 5);
|
ghost.play(defaultvolume - 0.3, 0.0, playbackspeed, 0.0, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
|||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.animation.Animation;
|
import javafx.animation.Animation;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@ -533,6 +534,15 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[0]) {
|
if(!gameStateModel.getKickedOff()[0]) {
|
||||||
Animation bell = new BellAnimation(noiseImage5, bells);
|
Animation bell = new BellAnimation(noiseImage5, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
|
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
@ -555,6 +565,14 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[1]) {
|
if(!gameStateModel.getKickedOff()[1]) {
|
||||||
Animation bell = new BellAnimation(noiseImage4, bells);
|
Animation bell = new BellAnimation(noiseImage4, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
@ -576,6 +594,15 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[2]) {
|
if(!gameStateModel.getKickedOff()[2]) {
|
||||||
Animation bell = new BellAnimation(noiseImage3, bells);
|
Animation bell = new BellAnimation(noiseImage3, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
|
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
@ -597,6 +624,15 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[3]) {
|
if(!gameStateModel.getKickedOff()[3]) {
|
||||||
Animation bell = new BellAnimation(noiseImage2, bells);
|
Animation bell = new BellAnimation(noiseImage2, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
|
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
@ -618,6 +654,15 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[4]) {
|
if(!gameStateModel.getKickedOff()[4]) {
|
||||||
Animation bell = new BellAnimation(noiseImage1, bells);
|
Animation bell = new BellAnimation(noiseImage1, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
|
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
@ -639,6 +684,14 @@ public class GameController implements Initializable {
|
|||||||
try {
|
try {
|
||||||
if(!gameStateModel.getKickedOff()[5]) {
|
if(!gameStateModel.getKickedOff()[5]) {
|
||||||
Animation bell = new BellAnimation(noiseImage0, bells);
|
Animation bell = new BellAnimation(noiseImage0, bells);
|
||||||
|
//wait until it's day:
|
||||||
|
while (!getGameStateModel().getDayClone()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
//just so the alarm isn't rung exactly when the day starts, add random delay
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.sleep(random.nextInt(1000));
|
||||||
bell.play();
|
bell.play();
|
||||||
ringBellSound();
|
ringBellSound();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,6 +207,11 @@ public class Protocol {
|
|||||||
*/
|
*/
|
||||||
public static final String printToGUI = "PTGUI";
|
public static final String printToGUI = "PTGUI";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent to a client to notify them that they heard a ghost noise, triggering the ghost SFX.
|
||||||
|
*/
|
||||||
|
public static final String noiseNotificationProtocol = "NOISE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an information to client at which position in the train from the game (0 to 5) they sit, as soon as the game starts
|
* Sends an information to client at which position in the train from the game (0 to 5) they sit, as soon as the game starts
|
||||||
* {@code POSOF$position}
|
* {@code POSOF$position}
|
||||||
|
|||||||
Reference in New Issue
Block a user