|
|
|
|
@ -83,6 +83,8 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
|
|
|
|
|
private StlMeshImporter importer;
|
|
|
|
|
|
|
|
|
|
private PopulatePlayers lobbyUpdateListener;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
|
|
allPlayerLabels = new ArrayList(Arrays.asList(playerLabel, playerLabel2,
|
|
|
|
|
@ -94,6 +96,8 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
URL asset = HostController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
|
|
|
|
importer = new StlMeshImporter();
|
|
|
|
|
importer.read(asset);
|
|
|
|
|
lobbyUpdateListener = new PopulatePlayers();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetLobby(){
|
|
|
|
|
@ -110,56 +114,69 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void populatePlayers(ListChangeListener.Change change){
|
|
|
|
|
|
|
|
|
|
Platform.runLater(
|
|
|
|
|
() -> {
|
|
|
|
|
while (change.next()){
|
|
|
|
|
if (change.wasAdded() || change.wasRemoved() || change.wasUpdated() || change.wasPermutated()){
|
|
|
|
|
try{
|
|
|
|
|
resetLobby();
|
|
|
|
|
int count = 0;
|
|
|
|
|
int row = 0;
|
|
|
|
|
for (VisualiserBoat boat :this.visualiserRaceEvent.getVisualiserRaceState().getBoats()) {
|
|
|
|
|
View3D playerBoatToSet = new View3D();
|
|
|
|
|
playerBoatToSet.setItems(subjects);
|
|
|
|
|
|
|
|
|
|
playerContainer.add(playerBoatToSet, (count % 3) , row);
|
|
|
|
|
playerContainer.setMargin(playerBoatToSet, new Insets(10, 10, 10, 10));
|
|
|
|
|
public class PopulatePlayers implements ListChangeListener {
|
|
|
|
|
|
|
|
|
|
MeshView mesh = new MeshView(importer.getImport());
|
|
|
|
|
Subject3D subject = new Subject3D(mesh);
|
|
|
|
|
subjects.add(subject);
|
|
|
|
|
@Override
|
|
|
|
|
public void onChanged(Change change) {
|
|
|
|
|
|
|
|
|
|
playerBoatToSet.setDistance(50);
|
|
|
|
|
playerBoatToSet.setYaw(45);
|
|
|
|
|
playerBoatToSet.setPitch(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AnimationTimer rotate = new AnimationTimer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(long now) {
|
|
|
|
|
subject.setHeading(subject.getHeading().getAngle() + 0.1);
|
|
|
|
|
Platform.runLater(
|
|
|
|
|
() -> {
|
|
|
|
|
if (visualiserRaceEvent.getVisualiserRaceState().getRaceStatusEnum() != RaceStatusEnum.PRESTART){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (change.next()){
|
|
|
|
|
if (change.wasAdded() || change.wasRemoved() || change.wasUpdated() || change.wasPermutated()){
|
|
|
|
|
if (visualiserRaceEvent.getVisualiserRaceState().getRaceStatusEnum() != RaceStatusEnum.PRESTART){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try{
|
|
|
|
|
resetLobby();
|
|
|
|
|
int count = 0;
|
|
|
|
|
int row = 0;
|
|
|
|
|
for (VisualiserBoat boat :visualiserRaceEvent.getVisualiserRaceState().getBoats()) {
|
|
|
|
|
View3D playerBoatToSet = new View3D();
|
|
|
|
|
playerBoatToSet.setItems(subjects);
|
|
|
|
|
|
|
|
|
|
playerContainer.add(playerBoatToSet, (count % 3) , row);
|
|
|
|
|
playerContainer.setMargin(playerBoatToSet, new Insets(10, 10, 10, 10));
|
|
|
|
|
|
|
|
|
|
MeshView mesh = new MeshView(importer.getImport());
|
|
|
|
|
Subject3D subject = new Subject3D(mesh);
|
|
|
|
|
subjects.add(subject);
|
|
|
|
|
|
|
|
|
|
playerBoatToSet.setDistance(50);
|
|
|
|
|
playerBoatToSet.setYaw(45);
|
|
|
|
|
playerBoatToSet.setPitch(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AnimationTimer rotate = new AnimationTimer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(long now) {
|
|
|
|
|
subject.setHeading(subject.getHeading().getAngle() + 0.1);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
rotate.start();
|
|
|
|
|
|
|
|
|
|
allPlayerLabels.get(count).setText("Player: " + boat.getSourceID());
|
|
|
|
|
allPlayerLabels.get(count).toFront();
|
|
|
|
|
count += 1;
|
|
|
|
|
if (count > 2){
|
|
|
|
|
row = 1;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
rotate.start();
|
|
|
|
|
|
|
|
|
|
allPlayerLabels.get(count).setText("Player: " + boat.getSourceID());
|
|
|
|
|
allPlayerLabels.get(count).toFront();
|
|
|
|
|
count += 1;
|
|
|
|
|
if (count > 2){
|
|
|
|
|
row = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(ConcurrentModificationException e){
|
|
|
|
|
catch(ConcurrentModificationException e){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
private void populatePlayers(ListChangeListener.Change change){
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the race.
|
|
|
|
|
@ -220,7 +237,7 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
|
|
|
|
|
//Hide this, and display the race controller.
|
|
|
|
|
gameLobbyWrapper.setVisible(false);
|
|
|
|
|
|
|
|
|
|
visualiserRaceEvent.getVisualiserRaceState().getBoats().removeListener(lobbyUpdateListener);
|
|
|
|
|
parent.beginRace(visualiserRaceEvent, controllerClient, isHost);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -239,9 +256,7 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
this.controllerClient = visualiserRaceEvent.getControllerClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.visualiserRaceEvent.getVisualiserRaceState().getBoats().addListener((ListChangeListener<? super VisualiserBoat>) c ->{
|
|
|
|
|
populatePlayers(c);
|
|
|
|
|
});
|
|
|
|
|
this.visualiserRaceEvent.getVisualiserRaceState().getBoats().addListener(this.lobbyUpdateListener);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameLobbyWrapper.setVisible(true);
|
|
|
|
|
|