Finally the fullWagon appears and disappears how it should (only at the very beginning there is still a lag, but i am on it)
This commit is contained in:
parent
d87dd237f7
commit
b9a59de09a
@ -127,10 +127,12 @@ public class Game implements Runnable {
|
||||
GhostPlayer ghostPlayer = new GhostPlayer(passengerTrain[index].getPosition(),
|
||||
client.getClientUserName(), client, passengerTrain[index].getIsOG());
|
||||
gameState.getPassengerTrain()[index] = ghostPlayer;
|
||||
client.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.yourPosition + "$" + ghostPlayer.getPosition());
|
||||
} else {
|
||||
HumanPlayer humanPlayer = new HumanPlayer(passengerTrain[index].getPosition(),
|
||||
client.getClientUserName(), client, passengerTrain[index].getIsOG());
|
||||
gameState.getPassengerTrain()[index] = humanPlayer;
|
||||
client.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.yourPosition + "$" + humanPlayer.getPosition());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ public class Timer {
|
||||
boolean[] whoHasVoted = game.getGameState().getClientVoteData().getHasVoted();
|
||||
Passenger[] passengerArray = game.getGameState().getPassengerTrain();
|
||||
for(int i = 0; i < whoHasVoted.length; i++) {
|
||||
if(!passengerArray[i].getIsGhost() && !whoHasVoted[i]) {
|
||||
if(!passengerArray[i].getIsGhost() && ! passengerArray[i].getKickedOff() && !whoHasVoted[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ public class Client {
|
||||
private ClientModel clientModel;
|
||||
private GameStateModel gameStateModel;
|
||||
private GameController gameController;
|
||||
private DayNightChangeListener dayNightChangeListener;
|
||||
|
||||
private GUI gui;
|
||||
|
||||
@ -147,6 +148,7 @@ public class Client {
|
||||
try {
|
||||
position = Integer.parseInt(pos);
|
||||
gameStateModel.setRoleFromPosition(position);
|
||||
dayNightChangeListener.setPosition(position);
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.warn("Position got scrabbled on the way here");
|
||||
}
|
||||
@ -351,9 +353,11 @@ public class Client {
|
||||
switch (parameter) {
|
||||
case GuiParameters.night: //ClientGameInfoHandler;
|
||||
gameStateModel.setDayClone(false);
|
||||
dayNightChangeListener.setNoiseButtonInvisible(true);
|
||||
break;
|
||||
case GuiParameters.day: //ClientGameInfoHandler
|
||||
gameStateModel.setDayClone(true);
|
||||
dayNightChangeListener.setNoiseButtonInvisible(false);
|
||||
break;
|
||||
case GuiParameters.updateGameState:
|
||||
gameStateModel.setGSFromString(data);
|
||||
@ -373,6 +377,7 @@ public class Client {
|
||||
case GuiParameters.VoteIsOver:
|
||||
chatApp.getGameController().setNoiseButtonInvisible();
|
||||
chatApp.getGameController().clearAllNoiseDisplay();
|
||||
dayNightChangeListener.setNoiseButtonInvisible(true);
|
||||
break;
|
||||
case GuiParameters.getMembersInLobby:
|
||||
updateLobbyMembers(data);
|
||||
@ -380,7 +385,8 @@ public class Client {
|
||||
case GuiParameters.viewChangeToGame:
|
||||
chatApp.getLoungeSceneViewController().addGameView();
|
||||
gameStateModel.setGameOver(false);
|
||||
new Thread(new DayNightChangeListener(gameStateModel, chatApp, position)).start();
|
||||
dayNightChangeListener = new DayNightChangeListener(gameStateModel, chatApp, Integer.MAX_VALUE);
|
||||
new Thread(dayNightChangeListener).start();
|
||||
break;
|
||||
case GuiParameters.viewChangeToLobby:
|
||||
chatApp.getLoungeSceneViewController().removeGameView();
|
||||
@ -396,6 +402,9 @@ public class Client {
|
||||
case GuiParameters.updateHighScore:
|
||||
chatApp.getLoungeSceneViewController().addHighScore(data);
|
||||
break;
|
||||
case GuiParameters.yourPosition:
|
||||
dayNightChangeListener.setPosition(Integer.parseInt(data));
|
||||
break;
|
||||
case GuiParameters.updatePrintLobby:
|
||||
chatApp.getLoungeSceneViewController().clearLobbyPrint();
|
||||
chatApp.getLoungeSceneViewController().addLobbyPrint(data);
|
||||
|
||||
@ -12,13 +12,20 @@ public class DayNightChangeListener implements Runnable {
|
||||
private GameStateModel gameStateModel;
|
||||
private ChatApp chatApp;
|
||||
private int position;
|
||||
private boolean noiseButtonInvisible;
|
||||
|
||||
public DayNightChangeListener(GameStateModel gameStateModel, ChatApp chatApp, int position) {
|
||||
this.gameStateModel = gameStateModel;
|
||||
this.chatApp = chatApp;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setNoiseButtonInvisible(boolean visible) {
|
||||
noiseButtonInvisible = visible;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -30,7 +37,9 @@ public class DayNightChangeListener implements Runnable {
|
||||
GameController.getGameStateModel().getKickedOff());
|
||||
chatApp.getGameController()
|
||||
.updateGameSprites(LoungeSceneViewController.getTrainAnimationDayController());
|
||||
chatApp.getGameController().setNoiseButtonVisible();
|
||||
if(!noiseButtonInvisible) {
|
||||
chatApp.getGameController().setNoiseButtonVisible();
|
||||
}
|
||||
chatApp.getGameController().setVoteButtonVisibilityDay(gameStateModel);
|
||||
} else { //its night
|
||||
try {
|
||||
|
||||
@ -101,4 +101,8 @@ public class GuiParameters {
|
||||
* Tells gui to remove a lobby from view. Form: {@code RMVLBY$<LobbyID>}
|
||||
*/
|
||||
public static final String removeLobby = "RMVLBY";
|
||||
/**
|
||||
* Tells the GUI at which position you are sitting {@code POSITION$integer}
|
||||
*/
|
||||
public static final String yourPosition = "POSITION";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user