mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch 'develop' into 1276_Next_Mark_Indicator
This commit is contained in:
@@ -80,12 +80,14 @@ public class App extends Application {
|
|||||||
ViewManager.getInstance().initialiseSplashScreen(primaryStage);
|
ViewManager.getInstance().initialiseSplashScreen(primaryStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runDiscoveryServer(){
|
private static void runDiscoveryServer() throws Exception {
|
||||||
try{
|
while (true){
|
||||||
new DiscoveryServer();
|
try {
|
||||||
}
|
new DiscoveryServer();
|
||||||
catch (Exception e){
|
}
|
||||||
runDiscoveryServer();
|
catch (Exception ignored){
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ import seng302.discoveryServer.util.ServerRepoStreamParser;
|
|||||||
import seng302.discoveryServer.util.ServerTable;
|
import seng302.discoveryServer.util.ServerTable;
|
||||||
import seng302.visualiser.ServerListener;
|
import seng302.visualiser.ServerListener;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Timer;
|
||||||
|
|
||||||
public class DiscoveryServer {
|
public class DiscoveryServer {
|
||||||
public static final String ANSI_GREEN = "\u001B[32m";
|
public static final String ANSI_GREEN = "\u001B[32m";
|
||||||
@@ -27,6 +29,7 @@ public class DiscoveryServer {
|
|||||||
|
|
||||||
private ServerTable serverTable;
|
private ServerTable serverTable;
|
||||||
public static final Integer PORT_NUMBER = 9969;
|
public static final Integer PORT_NUMBER = 9969;
|
||||||
|
private ServerSocket serverSocket;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(DiscoveryServer.class);
|
private final Logger logger = LoggerFactory.getLogger(DiscoveryServer.class);
|
||||||
|
|
||||||
@@ -56,8 +59,6 @@ public class DiscoveryServer {
|
|||||||
displayHeader();
|
displayHeader();
|
||||||
serverTable = new ServerTable();
|
serverTable = new ServerTable();
|
||||||
|
|
||||||
ServerSocket serverSocket;
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
serverSocket = new ServerSocket(PORT_NUMBER);
|
serverSocket = new ServerSocket(PORT_NUMBER);
|
||||||
}
|
}
|
||||||
@@ -69,12 +70,17 @@ public class DiscoveryServer {
|
|||||||
|
|
||||||
logger.info("Started successfully - Now accepting connections");
|
logger.info("Started successfully - Now accepting connections");
|
||||||
|
|
||||||
while (true){
|
try{
|
||||||
Socket clientSocket = serverSocket.accept();
|
while (true){
|
||||||
|
Socket clientSocket = serverSocket.accept();
|
||||||
|
|
||||||
parseRequest(clientSocket);
|
parseRequest(clientSocket);
|
||||||
|
|
||||||
clientSocket.close();
|
clientSocket.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +153,18 @@ public class DiscoveryServer {
|
|||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverToJoin != null && serverToJoin.isMaxPlayersReached()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return serverToJoin;
|
return serverToJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close(){
|
||||||
|
try {
|
||||||
|
serverSocket.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import seng302.gameServer.messages.*;
|
import seng302.gameServer.messages.BoatAction;
|
||||||
|
import seng302.gameServer.messages.BoatStatus;
|
||||||
|
import seng302.gameServer.messages.ChatterMessage;
|
||||||
|
import seng302.gameServer.messages.CustomizeRequestType;
|
||||||
|
import seng302.gameServer.messages.MarkRoundingMessage;
|
||||||
|
import seng302.gameServer.messages.MarkType;
|
||||||
|
import seng302.gameServer.messages.Message;
|
||||||
|
import seng302.gameServer.messages.RoundingBoatStatus;
|
||||||
import seng302.model.GeoPoint;
|
import seng302.model.GeoPoint;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.Player;
|
import seng302.model.Player;
|
||||||
@@ -20,7 +35,6 @@ import seng302.model.token.Token;
|
|||||||
import seng302.model.token.TokenType;
|
import seng302.model.token.TokenType;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.utilities.RandomSpawn;
|
import seng302.utilities.RandomSpawn;
|
||||||
import seng302.utilities.XMLParser;
|
|
||||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +341,7 @@ public class GameState implements Runnable {
|
|||||||
private void spawnNewToken() {
|
private void spawnNewToken() {
|
||||||
tokensInPlay.clear();
|
tokensInPlay.clear();
|
||||||
Token token = randomSpawn.getRandomToken();
|
Token token = randomSpawn.getRandomToken();
|
||||||
// token.assignType(TokenType.RANDOM);
|
// token.assignType(TokenType.WIND_WALKER);
|
||||||
logger.debug("Spawned token of type " + token.getTokenType());
|
logger.debug("Spawned token of type " + token.getTokenType());
|
||||||
tokensInPlay.add(token);
|
tokensInPlay.add(token);
|
||||||
MessageFactory.updateTokens(tokensInPlay);
|
MessageFactory.updateTokens(tokensInPlay);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
private boolean terminated;
|
private boolean terminated;
|
||||||
|
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
private boolean hasStarted = false;
|
||||||
|
|
||||||
private ServerSocket serverSocket = null;
|
private ServerSocket serverSocket = null;
|
||||||
private ArrayList<ServerToClientThread> serverToClientThreads = new ArrayList<>();
|
private ArrayList<ServerToClientThread> serverToClientThreads = new ArrayList<>();
|
||||||
@@ -98,6 +99,8 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
new HeartbeatThread(this);
|
new HeartbeatThread(this);
|
||||||
new ServerListenThread(serverSocket, this);
|
new ServerListenThread(serverSocket, this);
|
||||||
|
|
||||||
|
hasStarted = true;
|
||||||
|
|
||||||
//You should handle interrupts in some way, so that the thread won't keep on forever if you exit the app.
|
//You should handle interrupts in some way, so that the thread won't keep on forever if you exit the app.
|
||||||
while (!terminated) {
|
while (!terminated) {
|
||||||
if (GameState.getPlayerHasLeftFlag()) {
|
if (GameState.getPlayerHasLeftFlag()) {
|
||||||
@@ -146,8 +149,10 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (ServerToClientThread serverToClientThread : serverToClientThreads) {
|
synchronized (this){
|
||||||
serverToClientThread.terminate();
|
for (ServerToClientThread serverToClientThread : serverToClientThreads) {
|
||||||
|
serverToClientThread.terminate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
serverSocket.close();
|
serverSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -450,4 +455,8 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasStarted() {
|
||||||
|
return hasStarted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package seng302.visualiser;
|
package seng302.visualiser;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -13,7 +14,12 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
@@ -45,6 +51,8 @@ import seng302.visualiser.controllers.ViewManager;
|
|||||||
*/
|
*/
|
||||||
public class ClientToServerThread implements Runnable {
|
public class ClientToServerThread implements Runnable {
|
||||||
|
|
||||||
|
private boolean isStarted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functional interface for receiving packets from client socket.
|
* Functional interface for receiving packets from client socket.
|
||||||
*/
|
*/
|
||||||
@@ -120,6 +128,8 @@ public class ClientToServerThread implements Runnable {
|
|||||||
* variable is false.
|
* variable is false.
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
|
isStarted = true;
|
||||||
|
|
||||||
int sync1;
|
int sync1;
|
||||||
int sync2;
|
int sync2;
|
||||||
// TODO: 14/07/17 wmu16 - Work out how to fix this while loop
|
// TODO: 14/07/17 wmu16 - Work out how to fix this while loop
|
||||||
@@ -170,8 +180,10 @@ public class ClientToServerThread implements Runnable {
|
|||||||
notifyDisconnectListeners("Connection to server was terminated");
|
notifyDisconnectListeners("Connection to server was terminated");
|
||||||
closeSocket();
|
closeSocket();
|
||||||
|
|
||||||
ViewManager.getInstance().goToStartView();
|
Platform.runLater(() -> {
|
||||||
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
||||||
|
ViewManager.getInstance().goToStartView();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
|
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
|
||||||
@@ -197,12 +209,6 @@ public class ClientToServerThread implements Runnable {
|
|||||||
if (connectionErrorListener != null){
|
if (connectionErrorListener != null){
|
||||||
connectionErrorListener.notifyConnectionError(message);
|
connectionErrorListener.notifyConnectionError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
this.socket.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Couldn't close socket");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,9 +399,9 @@ public class ClientToServerThread implements Runnable {
|
|||||||
}
|
}
|
||||||
if (currentByte == -1) {
|
if (currentByte == -1) {
|
||||||
notifyDisconnectListeners("Cannot read from server.");
|
notifyDisconnectListeners("Cannot read from server.");
|
||||||
closeSocket();
|
|
||||||
logger.warn("InputStream reach end of stream", 1);
|
logger.warn("InputStream reach end of stream", 1);
|
||||||
handleConnectionError("Could not connect to server. Server is no longer available.");
|
handleConnectionError("Could not connect to server. Server is no longer available.");
|
||||||
|
closeSocket();
|
||||||
}
|
}
|
||||||
return currentByte;
|
return currentByte;
|
||||||
}
|
}
|
||||||
@@ -438,4 +444,8 @@ public class ClientToServerThread implements Runnable {
|
|||||||
).getBuffer()
|
).getBuffer()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasStarted() {
|
||||||
|
return isStarted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class GameClient {
|
|||||||
|
|
||||||
getServerThread().setConnectionErrorListener((eMessage) -> {
|
getServerThread().setConnectionErrorListener((eMessage) -> {
|
||||||
ViewManager.getInstance().showErrorSnackBar(eMessage);
|
ViewManager.getInstance().showErrorSnackBar(eMessage);
|
||||||
destroyClientToServerThread();
|
//destroyClientToServerThread();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lobbyController = ViewManager.getInstance().goToLobby(true);
|
this.lobbyController = ViewManager.getInstance().goToLobby(true);
|
||||||
@@ -147,18 +147,45 @@ public class GameClient {
|
|||||||
|
|
||||||
server = new MainServerThread();
|
server = new MainServerThread();
|
||||||
|
|
||||||
|
while (!server.hasStarted()){
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startClientToServerThread(ipAddress, 4942);
|
startClientToServerThread(ipAddress, 4942);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
showConnectionError("Cannot connect to server as host");
|
showConnectionError("Cannot connect to server as host");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for C2S thread
|
||||||
|
while (!socketThread.hasStarted()){
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
socketThread.sendXML(race, serverName, numLegs, maxPlayers, tokensEnabled);
|
socketThread.sendXML(race, serverName, numLegs, maxPlayers, tokensEnabled);
|
||||||
while (regattaData == null){
|
|
||||||
|
int triesLeft = 15;
|
||||||
|
|
||||||
|
while (regattaData == null && triesLeft > 0){
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
triesLeft--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triesLeft <= 0){
|
||||||
|
showConnectionError("Could not launch server");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lobbyController = ViewManager.getInstance().goToLobby(false);
|
this.lobbyController = ViewManager.getInstance().goToLobby(false);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import javafx.animation.RotateTransition;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
@@ -43,6 +44,7 @@ import javafx.scene.shape.Polyline;
|
|||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
|
import javafx.util.Duration;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
@@ -140,6 +142,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
private Timer blinkingTimer = new Timer();
|
private Timer blinkingTimer = new Timer();
|
||||||
private ImageView iconToDisplay;
|
private ImageView iconToDisplay;
|
||||||
|
|
||||||
|
private Double lastWindDirection;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
contentStackPane.setVisible(false);
|
contentStackPane.setVisible(false);
|
||||||
Image loadingImage = new Image("PP.png");
|
Image loadingImage = new Image("PP.png");
|
||||||
@@ -188,6 +192,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
chatHistory.decreaseOpacity();
|
chatHistory.decreaseOpacity();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lastWindDirection = 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
||||||
@@ -435,7 +441,13 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
*/
|
*/
|
||||||
private void updateWindDirection(double direction) {
|
private void updateWindDirection(double direction) {
|
||||||
windDirectionLabel.setText(String.format("%.1f°", direction));
|
windDirectionLabel.setText(String.format("%.1f°", direction));
|
||||||
windImageView.setRotate(direction);
|
RotateTransition rt = new RotateTransition(Duration.millis(300), windImageView);
|
||||||
|
rt.setByAngle(direction - lastWindDirection);
|
||||||
|
rt.setCycleCount(3);
|
||||||
|
rt.setAutoReverse(true);
|
||||||
|
rt.play();
|
||||||
|
lastWindDirection = direction;
|
||||||
|
// windImageView.setRotate(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -119,6 +119,12 @@ public class ServerCreationController implements Initializable {
|
|||||||
.runAsHost("localhost", 4941, serverName.getText(), (int) maxPlayersSlider
|
.runAsHost("localhost", 4941, serverName.getText(), (int) maxPlayersSlider
|
||||||
.getValue(), mapMaker.getCurrentRacePath(), (int) legsSlider.getValue(), pickupsCheckBox.isSelected());
|
.getValue(), mapMaker.getCurrentRacePath(), (int) legsSlider.getValue(), pickupsCheckBox.isSelected());
|
||||||
|
|
||||||
|
if (serverDescription == null){
|
||||||
|
ViewManager.getInstance().getGameClient().getServerThread().closeSocket();
|
||||||
|
ViewManager.getInstance().getGameClient().stopGame();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ViewManager.getInstance().setProperty("serverName", serverDescription.getName());
|
ViewManager.getInstance().setProperty("serverName", serverDescription.getName());
|
||||||
ViewManager.getInstance().setProperty("mapName", serverDescription.getMapName());
|
ViewManager.getInstance().setProperty("mapName", serverDescription.getMapName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public enum BoatMeshType {
|
|||||||
0.997, null, false, 1.0, 1.4, 2.0),
|
0.997, null, false, 1.0, 1.4, 2.0),
|
||||||
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
|
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
|
||||||
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 1.2),
|
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 1.2),
|
||||||
DUCKY("ducky_hull.stl", "ducky_mast.stl", -2.18539, "ducky_sail.stl", -2.18539, "ducky_eyes.stl", false, 1.2, 1.1, 1.4);
|
DUCKY("ducky_hull.stl", "ducky_mast.stl", -2.18539, "ducky_sail.stl", -2.18539, "ducky_eyes.stl", false, 1.2, 1.1, 1.4),
|
||||||
|
PARROT("parrot_hull.stl", null, 0, "parrot_sail.stl", 0, "parrot_features.stl", true, 1, 1, 1);
|
||||||
|
|
||||||
final String hullFile, mastFile, sailFile, jibFile;
|
final String hullFile, mastFile, sailFile, jibFile;
|
||||||
final double mastOffset, sailOffset;
|
final double mastOffset, sailOffset;
|
||||||
@@ -20,7 +21,7 @@ public enum BoatMeshType {
|
|||||||
public final double accelerationMultiplier;
|
public final double accelerationMultiplier;
|
||||||
public final double turnStep;
|
public final double turnStep;
|
||||||
final boolean fixedSail;
|
final boolean fixedSail;
|
||||||
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CATAMARAN, PIRATE_SHIP, DUCKY};
|
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CATAMARAN, PIRATE_SHIP, DUCKY, PARROT};
|
||||||
|
|
||||||
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile,
|
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile,
|
||||||
double sailOffset, String jibFile, boolean fixedSail, double maxSpeedMultiplier, double accelerationMultiplier, double turnStep) {
|
double sailOffset, String jibFile, boolean fixedSail, double maxSpeedMultiplier, double accelerationMultiplier, double turnStep) {
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public class BoatObject extends Group {
|
|||||||
private Color colour = Color.BLACK;
|
private Color colour = Color.BLACK;
|
||||||
private Boolean isSelected = false;
|
private Boolean isSelected = false;
|
||||||
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
||||||
|
// private Rotate tilt = new Rotate(0, new Point3D(0, 1, 0));
|
||||||
|
private double previousRotation = 0;
|
||||||
|
|
||||||
// This stuff only matters to the players boat object.
|
// This stuff only matters to the players boat object.
|
||||||
private Group markIndicator;
|
private Group markIndicator;
|
||||||
@@ -119,6 +121,14 @@ public class BoatObject extends Group {
|
|||||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||||
rotationProperty.set(heading);
|
rotationProperty.set(heading);
|
||||||
rotation.setAngle(heading);
|
rotation.setAngle(heading);
|
||||||
|
// if (heading == previousRotation) {
|
||||||
|
// tilt.setAngle(0);
|
||||||
|
// } else if (heading < previousRotation) {
|
||||||
|
// tilt.setAngle(-10);
|
||||||
|
// } else {
|
||||||
|
// tilt.setAngle(10);
|
||||||
|
// }
|
||||||
|
// previousRotation = heading;
|
||||||
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
||||||
if (sailsIn) {
|
if (sailsIn) {
|
||||||
boatAssets.showSail();
|
boatAssets.showSail();
|
||||||
|
|||||||
@@ -117,17 +117,25 @@ public class ModelFactory {
|
|||||||
Group boatAssets = new Group();
|
Group boatAssets = new Group();
|
||||||
MeshView hull = importSTL(boatType.hullFile);
|
MeshView hull = importSTL(boatType.hullFile);
|
||||||
hull.setMaterial(new PhongMaterial(primaryColour));
|
hull.setMaterial(new PhongMaterial(primaryColour));
|
||||||
MeshView mast = importSTL(boatType.mastFile);
|
|
||||||
mast.setMaterial(new PhongMaterial(primaryColour));
|
|
||||||
MeshView sail = importSTL(boatType.sailFile);
|
MeshView sail = importSTL(boatType.sailFile);
|
||||||
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
sail.setMaterial(
|
||||||
|
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
|
||||||
|
);
|
||||||
|
|
||||||
|
boatAssets.getChildren().addAll(hull, sail);
|
||||||
|
|
||||||
|
if (boatType.mastFile != null) {
|
||||||
|
MeshView mast = importSTL(boatType.mastFile);
|
||||||
|
mast.setMaterial(new PhongMaterial(primaryColour));
|
||||||
|
boatAssets.getChildren().add(mast);
|
||||||
|
}
|
||||||
|
|
||||||
if (boatType.jibFile != null) {
|
if (boatType.jibFile != null) {
|
||||||
MeshView jib = importSTL(boatType.jibFile);
|
MeshView jib = importSTL(boatType.jibFile);
|
||||||
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
sail.setMaterial(
|
||||||
boatAssets.getChildren().addAll(hull, mast, sail, jib);
|
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
|
||||||
} else {
|
);
|
||||||
boatAssets.getChildren().addAll(hull, mast, sail);
|
boatAssets.getChildren().add(jib);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boatAssets;
|
return boatAssets;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,16 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
<?import java.net.URL?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.Image?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
<StackPane id="background" fx:id="rootPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.SplashScreenController">
|
<StackPane id="background" fx:id="rootPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.SplashScreenController">
|
||||||
<stylesheets>
|
|
||||||
<String fx:value="/css/Master.css" />
|
|
||||||
<String fx:value="/css/SplashScreenView.css" />
|
|
||||||
</stylesheets>
|
|
||||||
<children>
|
<children>
|
||||||
<ImageView fitHeight="296.0" fitWidth="295.0" pickOnBounds="true" preserveRatio="true" StackPane.alignment="TOP_CENTER">
|
<ImageView fitHeight="296.0" fitWidth="295.0" pickOnBounds="true" preserveRatio="true" StackPane.alignment="TOP_CENTER">
|
||||||
<image>
|
<image>
|
||||||
@@ -29,4 +26,8 @@
|
|||||||
</StackPane.margin>
|
</StackPane.margin>
|
||||||
</Text>
|
</Text>
|
||||||
</children>
|
</children>
|
||||||
|
<stylesheets>
|
||||||
|
<URL value="@../css/Master.css"/>
|
||||||
|
<URL value="@../css/SplashScreenView.css"/>
|
||||||
|
</stylesheets>
|
||||||
</StackPane>
|
</StackPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user