mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Everything works. Needs a bit of polish, and possibly look at boat shapes next.
tags: #story[1142]
This commit is contained in:
@@ -60,6 +60,8 @@ public class GameState implements Runnable {
|
||||
public static Double windDirection;
|
||||
private static Double windSpeed;
|
||||
|
||||
private static Boolean customizationFlag;
|
||||
|
||||
private static String hostIpAddress;
|
||||
private static List<Player> players;
|
||||
private static Map<Integer, ServerYacht> yachts;
|
||||
@@ -91,6 +93,7 @@ public class GameState implements Runnable {
|
||||
yachts = new HashMap<>();
|
||||
players = new ArrayList<>();
|
||||
GameState.hostIpAddress = hostIpAddress;
|
||||
customizationFlag = false;
|
||||
|
||||
currentStage = GameStages.LOBBYING;
|
||||
isRaceStarted = false;
|
||||
@@ -668,4 +671,16 @@ public class GameState implements Runnable {
|
||||
public static void addMarkPassListener(NewMessageListener listener) {
|
||||
markListeners.add(listener);
|
||||
}
|
||||
|
||||
public static void setCustomizationFlag() {
|
||||
customizationFlag = true;
|
||||
}
|
||||
|
||||
public static Boolean getCustomizationFlag() {
|
||||
return customizationFlag;
|
||||
}
|
||||
|
||||
public static void resetCustomizationFlag() {
|
||||
customizationFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
||||
} catch (InterruptedException e) {
|
||||
serverLog("Interrupted exception in Main Server Thread thread sleep", 1);
|
||||
}
|
||||
|
||||
if (GameState.getCurrentStage() == GameStages.LOBBYING) {
|
||||
if (GameState.getCurrentStage() == GameStages.LOBBYING && GameState
|
||||
.getCustomizationFlag()) {
|
||||
// TODO: 16/08/17 ajm412: This can probably be done in a nicer way via those fancy functional interfaces.
|
||||
for (ServerToClientThread thread : serverToClientThreads) {
|
||||
thread.sendSetupMessages();
|
||||
}
|
||||
|
||||
GameState.resetCustomizationFlag();
|
||||
}
|
||||
|
||||
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
|
||||
|
||||
@@ -211,7 +211,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||
GameState.customizePlayer(sourceID, requestType,
|
||||
Arrays.copyOfRange(payload, 6, payload.length));
|
||||
sendSetupMessages();
|
||||
GameState.setCustomizationFlag();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -241,7 +241,7 @@ public class GameClient {
|
||||
);
|
||||
clientLobbyList.clear();
|
||||
allBoatsMap.forEach((id, boat) ->
|
||||
clientLobbyList.add(id + " " + boat.getBoatName())
|
||||
clientLobbyList.add(boat.getBoatName())
|
||||
);
|
||||
break;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ public class CustomizationController {
|
||||
|
||||
public void initialize() {
|
||||
|
||||
boatColorPicker.setValue(new Color(0.0, 0.0, 0.0, 1.0));
|
||||
|
||||
}
|
||||
|
||||
public void setServerThread(ClientToServerThread ctsThread) {
|
||||
@@ -56,6 +58,9 @@ public class CustomizationController {
|
||||
this.windowStage = stage;
|
||||
}
|
||||
|
||||
public void setPlayerName(String name) {
|
||||
this.nameField.setText(name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -149,9 +149,11 @@ public class LobbyController {
|
||||
try {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(LobbyController.class.getResource("/views/customizeView.fxml"));
|
||||
root = fxmlLoader.load();
|
||||
root.getStylesheets().add("/css/master.css");
|
||||
Stage customizeStage = new Stage();
|
||||
CustomizationController cc = fxmlLoader.getController();
|
||||
cc.setServerThread(this.socketThread);
|
||||
cc.setPlayerName(this.players.get(playerID - 1));
|
||||
customizeStage.setTitle("Customize Boat");
|
||||
customizeStage.setScene(new Scene(root, 700, 450));
|
||||
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
|
||||
|
||||
Reference in New Issue
Block a user