mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Started work on start screen
- Server now sends out race start status messages during lobby & pre-start stages - Added timer in lobby Tags: #story[1109]
This commit is contained in:
@@ -45,6 +45,7 @@ public class GameClient {
|
||||
private RegattaXMLData regattaData;
|
||||
private RaceXMLData courseData;
|
||||
private RaceState raceState = new RaceState();
|
||||
private LobbyController lobbyController;
|
||||
|
||||
private ObservableList<String> clientLobbyList = FXCollections.observableArrayList();
|
||||
|
||||
@@ -67,8 +68,10 @@ public class GameClient {
|
||||
LobbyController lobbyController = loadLobby();
|
||||
lobbyController.setPlayerListSource(clientLobbyList);
|
||||
lobbyController.disableReadyButton();
|
||||
lobbyController.setTitle("Connected to host - IP : " + ipAddress + " Port : " + portNumber);
|
||||
lobbyController.setTitle(regattaData.getRegattaName());
|
||||
lobbyController.setCourseName(regattaData.getCourseName());
|
||||
lobbyController.addCloseListener((exitCause) -> this.loadStartScreen());
|
||||
this.lobbyController = lobbyController;
|
||||
}
|
||||
|
||||
public void runAsHost(String ipAddress, Integer portNumber) {
|
||||
@@ -82,7 +85,8 @@ public class GameClient {
|
||||
socketThread.addStreamObserver(this::parsePackets);
|
||||
LobbyController lobbyController = loadLobby();
|
||||
lobbyController.setPlayerListSource(clientLobbyList);
|
||||
lobbyController.setTitle("Hosting Lobby - IP : " + ipAddress + " Port : " + portNumber);
|
||||
lobbyController.setTitle("Hosting: " + regattaData.getRegattaName());
|
||||
lobbyController.setCourseName(regattaData.getCourseName());
|
||||
lobbyController.addCloseListener(exitCause -> {
|
||||
if (exitCause == CloseStatus.READY) {
|
||||
server.startGame();
|
||||
@@ -90,6 +94,8 @@ public class GameClient {
|
||||
loadStartScreen();
|
||||
}
|
||||
});
|
||||
|
||||
this.lobbyController = lobbyController;
|
||||
}
|
||||
|
||||
private void loadStartScreen() {
|
||||
@@ -151,13 +157,18 @@ public class GameClient {
|
||||
switch (packet.getType()) {
|
||||
case RACE_STATUS:
|
||||
processRaceStatusUpdate(StreamParser.extractRaceStatus(packet));
|
||||
startRaceIfAllDataReceived();
|
||||
|
||||
if (raceState.getTimeTillStart() <= 5){
|
||||
startRaceIfAllDataReceived();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case REGATTA_XML:
|
||||
regattaData = XMLParser.parseRegatta(
|
||||
StreamParser.extractXmlMessage(packet)
|
||||
);
|
||||
|
||||
raceState.setTimeZone(
|
||||
TimeZone.getTimeZone(
|
||||
ZoneId.ofOffset("UTC", ZoneOffset.ofHours(regattaData.getUtcOffset()))
|
||||
@@ -189,6 +200,7 @@ public class GameClient {
|
||||
|
||||
case RACE_START_STATUS:
|
||||
raceState.updateState(StreamParser.extractRaceStartStatus(packet));
|
||||
if (lobbyController != null) lobbyController.updateRaceState(raceState);
|
||||
break;
|
||||
|
||||
case BOAT_LOCATION:
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package seng302.visualiser.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
@@ -16,6 +15,8 @@ import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.text.Text;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.model.RaceState;
|
||||
import seng302.visualiser.GameClient;
|
||||
|
||||
/**
|
||||
* A class describing the actions of the lobby screen
|
||||
@@ -72,6 +73,12 @@ public class LobbyController {
|
||||
@FXML
|
||||
private ImageView eighthImageView;
|
||||
|
||||
@FXML
|
||||
private Text timeUntilStart;
|
||||
|
||||
@FXML
|
||||
private Text courseNameText;
|
||||
|
||||
private List<ObservableList<String>> competitors = new ArrayList<>();
|
||||
private ObservableList<String> firstCompetitor = FXCollections.observableArrayList();
|
||||
private ObservableList<String> secondCompetitor = FXCollections.observableArrayList();
|
||||
@@ -84,6 +91,7 @@ public class LobbyController {
|
||||
|
||||
private List<ImageView> imageViews = new ArrayList<>();
|
||||
private List<ListView> listViews;
|
||||
private RaceState raceState;
|
||||
|
||||
private int MAX_NUM_PLAYERS = 8;
|
||||
|
||||
@@ -103,6 +111,8 @@ public class LobbyController {
|
||||
fourthCompetitor, fifthCompetitor, sixthCompetitor, seventhCompetitor, eighthCompetitor);
|
||||
|
||||
initialiseImageView();
|
||||
|
||||
timeUntilStart.setText("");
|
||||
}
|
||||
|
||||
private void initialiseListView() {
|
||||
@@ -149,9 +159,12 @@ public class LobbyController {
|
||||
|
||||
@FXML
|
||||
public void readyButtonPressed() {
|
||||
GameState.setCurrentStage(GameStages.RACING);
|
||||
for (LobbyCloseListener readyListener : lobbyListeners)
|
||||
readyListener.notify(CloseStatus.READY);
|
||||
GameState.setCurrentStage(GameStages.PRE_RACE);
|
||||
return;
|
||||
// Do countdown logic here
|
||||
|
||||
//for (LobbyCloseListener readyListener : lobbyListeners)
|
||||
// readyListener.notify(CloseStatus.READY);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +197,10 @@ public class LobbyController {
|
||||
lobbyIpText.setText(title);
|
||||
}
|
||||
|
||||
public void setCourseName(String courseName){
|
||||
courseNameText.setText(courseName);
|
||||
}
|
||||
|
||||
public void addCloseListener(LobbyCloseListener listener) {
|
||||
lobbyListeners.add(listener);
|
||||
}
|
||||
@@ -196,6 +213,12 @@ public class LobbyController {
|
||||
Platform.runLater(this::initialiseListView);
|
||||
}
|
||||
|
||||
public void updateRaceState(RaceState raceState){
|
||||
System.out.println(raceState.getTimeTillStart());
|
||||
this.raceState = raceState;
|
||||
timeUntilStart.setText(raceState.getTimeTillStartStr());
|
||||
}
|
||||
|
||||
public void disableReadyButton () {
|
||||
readyButton.setDisable(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user