npcs no longer chat about hearing noise, ghost players hear ghost noise too, removed random ghost noise pitch even though it was super cool, because of stupid aliasing artefacts :(
This commit is contained in:
parent
2d6e15a39f
commit
7761a74d2b
@ -6,3 +6,4 @@ serai
|
|||||||
serai
|
serai
|
||||||
serai
|
serai
|
||||||
serai
|
serai
|
||||||
|
Jonas
|
||||||
|
|||||||
@ -24,11 +24,11 @@ public class NoiseHandler {
|
|||||||
public int[] noiseNotifier(Passenger predator, Passenger victim, int[] noiseAmount) {
|
public int[] noiseNotifier(Passenger predator, Passenger victim, int[] noiseAmount) {
|
||||||
if (predator.getPosition() - victim.getPosition()
|
if (predator.getPosition() - victim.getPosition()
|
||||||
> 0) { // if predator is to the right of victim
|
> 0) { // if predator is to the right of victim
|
||||||
for (int i = predator.getPosition() - 1; i > victim.getPosition(); i--) {
|
for (int i = predator.getPosition() ; i > victim.getPosition(); i--) { //-1
|
||||||
noiseAmount[i]++;
|
noiseAmount[i]++;
|
||||||
}
|
}
|
||||||
} else { // if predator is to the left of victim
|
} else { // if predator is to the left of victim
|
||||||
for (int i = predator.getPosition() + 1; i < victim.getPosition(); i++) {
|
for (int i = predator.getPosition(); i < victim.getPosition(); i++) { //+1
|
||||||
noiseAmount[i]++;
|
noiseAmount[i]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,14 +121,13 @@ public class ServerGameInfoHandler {
|
|||||||
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:
|
case ClientGameInfoHandler.noiseNotification:
|
||||||
//todo: jonas: handle bell behaviour correctly.
|
|
||||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
|
||||||
//TODO: add likelyhood
|
|
||||||
if(!npc.getKickedOff()) {
|
if(!npc.getKickedOff()) {
|
||||||
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
if (Math.random() < GhostNPC.probabilityToRingAlarmIfHeardNoise) {
|
||||||
game.getLobby().getAdmin().sendMsgToClientsInLobby(
|
game.getLobby().getAdmin().sendMsgToClientsInLobby(
|
||||||
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
||||||
+ "$" + npc.getPosition());
|
+ "$" + npc.getPosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ClientGameInfoHandler.ghostVoteRequest:
|
case ClientGameInfoHandler.ghostVoteRequest:
|
||||||
@ -151,13 +150,13 @@ public class ServerGameInfoHandler {
|
|||||||
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.
|
case ClientGameInfoHandler.noiseNotification: //new case where times are not noted.
|
||||||
//todo: jonas: handle bell behaviour correctly.
|
|
||||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
|
||||||
if(!npc.getKickedOff()) {
|
if(!npc.getKickedOff()) {
|
||||||
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
if (Math.random() < HumanNPC.probabilityToRingAlarmIfHeardNoise) {
|
||||||
game.getLobby().getAdmin().sendMsgToClientsInLobby(
|
game.getLobby().getAdmin().sendMsgToClientsInLobby(
|
||||||
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
||||||
+ "$" + npc.getPosition());
|
+ "$" + npc.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ClientGameInfoHandler.humanVoteRequest:
|
case ClientGameInfoHandler.humanVoteRequest:
|
||||||
|
|||||||
@ -172,7 +172,7 @@ public class VoteHandler {
|
|||||||
ClientGameInfoHandler.humansVotedFor + voteIndex + ClientGameInfoHandler.isAHuman, game);
|
ClientGameInfoHandler.humansVotedFor + voteIndex + ClientGameInfoHandler.isAHuman, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
@ -200,6 +200,8 @@ public class VoteHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Timer.humanAfterVoteTimer();
|
||||||
|
|
||||||
LOGGER.info(game.getGameState().toString());
|
LOGGER.info(game.getGameState().toString());
|
||||||
// set hasVoted to false for all passengers for future voting
|
// set hasVoted to false for all passengers for future voting
|
||||||
for (Passenger passenger : passengers) {
|
for (Passenger passenger : passengers) {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
public class GhostNPC extends Ghost {
|
public class GhostNPC extends Ghost {
|
||||||
public static final Logger LOGGER = LogManager.getLogger(GhostNPC.class);
|
public static final Logger LOGGER = LogManager.getLogger(GhostNPC.class);
|
||||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
public static final double probabilityToRingAlarmIfHeardNoise = 0.5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
|
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
|
||||||
|
|||||||
@ -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;
|
||||||
@ -14,6 +15,7 @@ public class GhostPlayer extends Ghost {
|
|||||||
public static final Logger LOGGER = LogManager.getLogger(GhostPlayer.class);
|
public static final Logger LOGGER = LogManager.getLogger(GhostPlayer.class);
|
||||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
||||||
* ghost.
|
* ghost.
|
||||||
@ -48,6 +50,8 @@ public class GhostPlayer extends Ghost {
|
|||||||
String formattedMsg;
|
String formattedMsg;
|
||||||
if (msg.equals(GuiParameters.updateGameState)) {
|
if (msg.equals(GuiParameters.updateGameState)) {
|
||||||
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
|
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
|
||||||
|
} else if (msg.equals(ClientGameInfoHandler.noiseNotification)) {
|
||||||
|
formattedMsg = Protocol.noiseNotificationProtocol;
|
||||||
} else {
|
} else {
|
||||||
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ public class HumanNPC extends Human {
|
|||||||
|
|
||||||
public static final Logger LOGGER = LogManager.getLogger(HumanNPC.class);
|
public static final Logger LOGGER = LogManager.getLogger(HumanNPC.class);
|
||||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
public static final double probabilityToRingAlarmIfHeardNoise = 0.9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new HumanNPC.
|
* Creates a new HumanNPC.
|
||||||
|
|||||||
@ -95,7 +95,9 @@ public class Sound {
|
|||||||
nightnoises.stop();
|
nightnoises.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void gameoverghosts() { gameoverghosts.play(defaultvolume); }
|
public static void gameoverghosts() {
|
||||||
|
stopmusicday();
|
||||||
|
gameoverghosts.play(defaultvolume); }
|
||||||
|
|
||||||
public static void gameoverhumans() {
|
public static void gameoverhumans() {
|
||||||
stopmusicday();
|
stopmusicday();
|
||||||
@ -116,7 +118,8 @@ public class Sound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ghost() {
|
public static void ghost() {
|
||||||
double playbackspeed = (Math.random() / 5.0) + 0.9;
|
//double playbackspeed = (Math.random() / 5.0) + 0.9; causes aliasing artefacts :/
|
||||||
|
double playbackspeed = 1;
|
||||||
int ghostsoundnr = random.nextInt(4) + 1;
|
int ghostsoundnr = random.nextInt(4) + 1;
|
||||||
System.out.println(ghostsoundnr);
|
System.out.println(ghostsoundnr);
|
||||||
AudioClip ghost;
|
AudioClip ghost;
|
||||||
@ -134,7 +137,7 @@ public class Sound {
|
|||||||
ghost = ghost04;
|
ghost = ghost04;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ghost.play(0.1, 0.0, playbackspeed, 0.0, 5);
|
ghost.play(0.06, 0.0, playbackspeed, 0.0, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user