mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'develop' into story1118_map_arrows
# Conflicts: # src/main/java/seng302/gameServer/GameState.java # src/main/java/seng302/gameServer/MainServerThread.java # src/main/java/seng302/model/RaceState.java # src/main/java/seng302/visualiser/GameClient.java
This commit is contained in:
@@ -12,6 +12,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.MainServerThread;
|
||||
import seng302.gameServer.messages.BoatAction;
|
||||
import seng302.model.ClientYacht;
|
||||
@@ -46,6 +47,7 @@ public class GameClient {
|
||||
private RegattaXMLData regattaData;
|
||||
private RaceXMLData courseData;
|
||||
private RaceState raceState = new RaceState();
|
||||
private LobbyController lobbyController;
|
||||
|
||||
private ObservableList<String> clientLobbyList = FXCollections.observableArrayList();
|
||||
|
||||
@@ -75,8 +77,18 @@ public class GameClient {
|
||||
LobbyController lobbyController = loadLobby();
|
||||
lobbyController.setPlayerListSource(clientLobbyList);
|
||||
lobbyController.disableReadyButton();
|
||||
lobbyController.setTitle("Connected to host - IP : " + ipAddress + " Port : " + portNumber);
|
||||
|
||||
if (regattaData != null){
|
||||
lobbyController.setTitle(regattaData.getRegattaName());
|
||||
lobbyController.setCourseName(regattaData.getCourseName());
|
||||
}
|
||||
else{
|
||||
lobbyController.setTitle(ipAddress);
|
||||
lobbyController.setCourseName("");
|
||||
}
|
||||
|
||||
lobbyController.addCloseListener((exitCause) -> this.loadStartScreen());
|
||||
this.lobbyController = lobbyController;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,15 +107,27 @@ public class GameClient {
|
||||
socketThread.addStreamObserver(this::parsePackets);
|
||||
LobbyController lobbyController = loadLobby();
|
||||
lobbyController.setPlayerListSource(clientLobbyList);
|
||||
lobbyController.setTitle("Hosting Lobby - IP : " + ipAddress + " Port : " + portNumber);
|
||||
|
||||
if (regattaData != null){
|
||||
lobbyController.setTitle("Hosting: " + regattaData.getRegattaName());
|
||||
lobbyController.setCourseName(regattaData.getCourseName());
|
||||
}
|
||||
else{
|
||||
lobbyController.setTitle("Hosting: " + ipAddress);
|
||||
lobbyController.setCourseName("");
|
||||
}
|
||||
|
||||
lobbyController.addCloseListener(exitCause -> {
|
||||
if (exitCause == CloseStatus.READY) {
|
||||
GameState.resetStartTime();
|
||||
lobbyController.disableReadyButton();
|
||||
server.startGame();
|
||||
} else if (exitCause == CloseStatus.LEAVE) {
|
||||
loadStartScreen();
|
||||
}
|
||||
});
|
||||
|
||||
this.lobbyController = lobbyController;
|
||||
server.setGameClient(this);
|
||||
}
|
||||
|
||||
@@ -175,13 +199,18 @@ public class GameClient {
|
||||
switch (packet.getType()) {
|
||||
case RACE_STATUS:
|
||||
processRaceStatusUpdate(StreamParser.extractRaceStatus(packet));
|
||||
startRaceIfAllDataReceived();
|
||||
|
||||
if (raceState.getTimeTillStart() <= 5000) {
|
||||
startRaceIfAllDataReceived();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case REGATTA_XML:
|
||||
regattaData = XMLParser.parseRegatta(
|
||||
StreamParser.extractXmlMessage(packet)
|
||||
);
|
||||
|
||||
raceState.setTimeZone(
|
||||
TimeZone.getTimeZone(
|
||||
ZoneId.ofOffset("UTC", ZoneOffset.ofHours(regattaData.getUtcOffset()))
|
||||
@@ -210,6 +239,7 @@ public class GameClient {
|
||||
|
||||
case RACE_START_STATUS:
|
||||
raceState.updateState(StreamParser.extractRaceStartStatus(packet));
|
||||
if (lobbyController != null) lobbyController.updateRaceState(raceState);
|
||||
break;
|
||||
|
||||
case BOAT_LOCATION:
|
||||
@@ -294,7 +324,8 @@ public class GameClient {
|
||||
raceFinished = false;
|
||||
}
|
||||
}
|
||||
if (raceFinished) {
|
||||
if (raceFinished == true) {
|
||||
close();
|
||||
loadFinishScreenView();
|
||||
}
|
||||
|
||||
@@ -340,14 +371,15 @@ public class GameClient {
|
||||
socketThread.sendBoatAction(BoatAction.TACK_GYBE); break;
|
||||
//TODO Allow a zoom in and zoom out methods
|
||||
case Z: // zoom in
|
||||
System.out.println("Zoom in");
|
||||
raceView.getGameView().zoomIn();
|
||||
break;
|
||||
case X: // zoom out
|
||||
System.out.println("Zoom out");
|
||||
raceView.getGameView().zoomOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void keyReleased(KeyEvent e) {
|
||||
switch (e.getCode()) {
|
||||
//TODO 12/07/17 Determine the sail state and send the appropriate packet (eg. if sails are in, send a sail out packet)
|
||||
|
||||
Reference in New Issue
Block a user