Fikser noen problemer

Fikser et problem der kortvelgingsmenyen ikke dukker opp på når sending av elementer går for raskt
Fikser tilstand til kortvelgingsskjermen slik at en ikke mister valgte kort når en ser på brettet
Fikser problemer med å fjerne døde spillere
Avslutter spillet på korrekt måte når alle spillere er døde
Fjerner udp portnummer siden UDP ikke blir brukt
This commit is contained in:
2020-04-20 21:43:47 +02:00
parent 13730dd592
commit 17a3d4f27a
17 changed files with 143 additions and 107 deletions

View File

@@ -23,9 +23,28 @@ public class ScreenManager {
private WinnerScreen winnerScreen;
private CardChoiceScreen cardChoiceScreen;
/**
* Gets a new instance of the card choice screen
*
* @param roboRallyWrapper The Robo Rally launcher instance to use
* @return A new card choice screen instance
*/
public synchronized CardChoiceScreen getNewCardChoiceScreen(RoboRallyWrapper roboRallyWrapper) {
this.cardChoiceScreen = new CardChoiceScreen(roboRallyWrapper);
return cardChoiceScreen;
}
/**
* Gets an instance of the card choice screen
*
* @param roboRallyWrapper The Robo Rally launcher instance to use
* @return A card choice screen instance
*/
public synchronized CardChoiceScreen getCardChoiceScreen(RoboRallyWrapper roboRallyWrapper) {
return new CardChoiceScreen(roboRallyWrapper);
if (this.cardChoiceScreen == null) {
this.cardChoiceScreen = new CardChoiceScreen(roboRallyWrapper);
}
return cardChoiceScreen;
}
/**

View File

@@ -77,14 +77,20 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
roboRallyWrapper.batch.end();
// Checks if there has been found a winning player and then changes the screen to display the winning screen
if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.GAME_IS_WON) {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getWinnerScreen(roboRallyWrapper));
} else if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.CHOOSING_STAY_IN_POWER_DOWN) {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
} else if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.LOADING){
roboRallyWrapper.client.sendElement(false);
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
switch (roboRallyWrapper.roboRallyGame.getGameState()) {
case GAME_IS_WON:
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getWinnerScreen(roboRallyWrapper));
break;
case CHOOSING_STAY_IN_POWER_DOWN:
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
break;
case LOADING:
roboRallyWrapper.client.sendElement(false);
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
break;
default:
//Ignored
break;
}
}

View File

@@ -63,7 +63,10 @@ public class LoadingScreen extends AbstractScreen {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
break;
case CHOOSING_CARDS:
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getCardChoiceScreen(this.roboRallyWrapper));
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getNewCardChoiceScreen(this.roboRallyWrapper));
break;
case EXITED:
roboRallyWrapper.quit("All players died. Cannot continue playing.");
break;
default:
System.out.println("The loading screen doesn't know what to do with " + gameState);

View File

@@ -84,17 +84,18 @@ public class PowerDownScreen extends AbstractScreen {
switch (roboRallyWrapper.roboRallyGame.getGameState()) {
case CHOOSING_STAY_IN_POWER_DOWN:
roboRallyWrapper.roboRallyGame.setGameState(GameState.TURN_CLEANUP);
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
roboRallyWrapper.client.sendElement(bool);
break;
case CHOOSING_POWER_DOWN:
roboRallyWrapper.roboRallyGame.setGameState(GameState.LOADING);
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
roboRallyWrapper.client.sendElement(new ProgramAndPowerdownRequest(bool,
roboRallyWrapper.roboRallyGame.getProgram()));
break;
default:
throw new IllegalStateException("The game is in an unexpected state. Cannot continue.");
}
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
}
@Override