|
|
|
|
@ -8,7 +8,9 @@ import javafx.collections.ListChangeListener;
|
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
|
import javafx.geometry.Insets;
|
|
|
|
|
import javafx.scene.AmbientLight;
|
|
|
|
|
import javafx.scene.Node;
|
|
|
|
|
import javafx.scene.PointLight;
|
|
|
|
|
import javafx.scene.control.Alert;
|
|
|
|
|
import javafx.scene.control.ButtonType;
|
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
|
@ -21,17 +23,12 @@ import javafx.scene.shape.MeshView;
|
|
|
|
|
import mock.app.Event;
|
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
|
import network.Messages.Enums.RequestToJoinEnum;
|
|
|
|
|
import shared.model.Boat;
|
|
|
|
|
import visualiser.app.App;
|
|
|
|
|
import visualiser.gameController.ControllerClient;
|
|
|
|
|
import visualiser.layout.SeaSurface;
|
|
|
|
|
import visualiser.layout.Shockwave;
|
|
|
|
|
import visualiser.layout.Subject3D;
|
|
|
|
|
import visualiser.layout.View3D;
|
|
|
|
|
import visualiser.layout.*;
|
|
|
|
|
import visualiser.model.VisualiserBoat;
|
|
|
|
|
import visualiser.model.VisualiserRaceEvent;
|
|
|
|
|
import visualiser.model.VisualiserRaceState;
|
|
|
|
|
import visualiser.network.HttpMatchBrowserHost;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.Socket;
|
|
|
|
|
@ -74,10 +71,8 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
private Label countdownLabel;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
private AnchorPane countdownTenPane;
|
|
|
|
|
private GridPane animatedPane;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
private Label countdownTenText;
|
|
|
|
|
|
|
|
|
|
private Event game;
|
|
|
|
|
|
|
|
|
|
@ -110,6 +105,60 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
importer.read(asset);
|
|
|
|
|
lobbyUpdateListener = new PopulatePlayers();
|
|
|
|
|
|
|
|
|
|
AmbientLight ambientLight = new AmbientLight(Color.web("#888888"));
|
|
|
|
|
ambientLight.setTranslateX(250);
|
|
|
|
|
ambientLight.setTranslateZ(210);
|
|
|
|
|
ambientLight.setLightOn(true);
|
|
|
|
|
|
|
|
|
|
PointLight pointLight = new PointLight(Color.web("#888888"));
|
|
|
|
|
pointLight.setTranslateX(250);
|
|
|
|
|
pointLight.setTranslateZ(210);
|
|
|
|
|
pointLight.setLightOn(true);
|
|
|
|
|
|
|
|
|
|
ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
|
|
|
|
View3D view3D = new View3D();
|
|
|
|
|
view3D.addAmbientLight(ambientLight);
|
|
|
|
|
view3D.addPointLight(pointLight);
|
|
|
|
|
view3D.setDistance(10);
|
|
|
|
|
view3D.setPitch(5);
|
|
|
|
|
view3D.setItems(subjects);
|
|
|
|
|
|
|
|
|
|
SkyBox skyBox = new SkyBox(750,200,250,0,250);
|
|
|
|
|
subjects.addAll(skyBox.getSkyBoxPlanes());
|
|
|
|
|
|
|
|
|
|
SeaSurface seaSurface = new SeaSurface(750, 200);
|
|
|
|
|
seaSurface.setX(250);
|
|
|
|
|
seaSurface.setZ(250);
|
|
|
|
|
subjects.add(seaSurface);
|
|
|
|
|
|
|
|
|
|
asset = RaceViewController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
|
|
|
|
StlMeshImporter importer = new StlMeshImporter();
|
|
|
|
|
importer.read(asset);
|
|
|
|
|
Subject3D boat = new Subject3D(new MeshView(importer.getImport()), 0);
|
|
|
|
|
|
|
|
|
|
double radius = 100;
|
|
|
|
|
boat.setX(0);
|
|
|
|
|
boat.setZ(radius);
|
|
|
|
|
boat.setScale(0.1);
|
|
|
|
|
|
|
|
|
|
subjects.add(boat);
|
|
|
|
|
view3D.trackSubject(boat, -45);
|
|
|
|
|
|
|
|
|
|
animatedPane.add(view3D, 0, 0);
|
|
|
|
|
|
|
|
|
|
AnimationTimer loop = new AnimationTimer() {
|
|
|
|
|
double angle = -90;
|
|
|
|
|
double offset = 0.05;
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(long now) {
|
|
|
|
|
boat.setX(radius * Math.cos(angle * Math.PI/180));
|
|
|
|
|
boat.setZ(radius * Math.sin(angle * Math.PI/180));
|
|
|
|
|
boat.setHeading(-angle);
|
|
|
|
|
angle += offset;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
loop.start();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetLobby(){
|
|
|
|
|
@ -250,20 +299,6 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
//Get the current race status.
|
|
|
|
|
RaceStatusEnum raceStatus = visualiserRaceEvent.getVisualiserRaceState().getRaceStatusEnum();
|
|
|
|
|
|
|
|
|
|
//Try catch for getting interval times
|
|
|
|
|
try {
|
|
|
|
|
long interval = ChronoUnit.MILLIS.between(visualiserRaceEvent.getVisualiserRaceState().getRaceClock().getCurrentTime(), visualiserRaceEvent.getVisualiserRaceState().getRaceClock().getStartingTime());
|
|
|
|
|
if(interval<=10000){
|
|
|
|
|
countdownLabel.setVisible(false);
|
|
|
|
|
countdownTenPane.setVisible(true);
|
|
|
|
|
countdownTenText.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
countdownText(interval);
|
|
|
|
|
} catch (Exception e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//If the race has reached the preparatory phase, or has started...
|
|
|
|
|
if (raceStatus == RaceStatusEnum.PREPARATORY || raceStatus == RaceStatusEnum.STARTED) {
|
|
|
|
|
//Stop this timer.
|
|
|
|
|
@ -346,48 +381,5 @@ public class InGameLobbyController extends Controller {
|
|
|
|
|
//System.out.println("Empty race user pane pressed. Joining racers");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Countdown interval checker that updates the countdown text
|
|
|
|
|
* @param interval Countdown interval to check
|
|
|
|
|
*/
|
|
|
|
|
private void countdownText(long interval){
|
|
|
|
|
countdownTenPane.setVisible(false);
|
|
|
|
|
//Do nothing if 5 seconds or less to go
|
|
|
|
|
if (interval <=5000){
|
|
|
|
|
countdownTenPane.setVisible(false);
|
|
|
|
|
//countdownTenText.setText("5");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//6 seconds left. Display 1 second for countdown
|
|
|
|
|
if (interval <=6000){
|
|
|
|
|
countdownTenText.setText("1");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//7 seconds left. Display 2 seconds for countdown
|
|
|
|
|
if (interval <=7000){
|
|
|
|
|
countdownTenText.setText("2");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//8 seconds left. Display 3 seconds for countdown
|
|
|
|
|
if (interval <=8000){
|
|
|
|
|
countdownTenText.setText("3");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//9 seconds left. Display 4 seconds for countdown
|
|
|
|
|
if (interval <=9000){
|
|
|
|
|
countdownTenText.setText("4");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//10 seconds left. Display 5 seconds for countdown
|
|
|
|
|
if (interval <=10000){
|
|
|
|
|
countdownTenText.setText("5");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|