mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch 'develop' into Story1278_keybindings
# Conflicts: # src/main/java/seng302/model/ServerYacht.java
This commit is contained in:
@@ -475,7 +475,7 @@ public class GameState implements Runnable {
|
|||||||
private void updateVelocity(ServerYacht yacht) {
|
private void updateVelocity(ServerYacht yacht) {
|
||||||
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
|
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
|
||||||
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
|
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
|
||||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * speedMultiplier;
|
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * speedMultiplier * yacht.getMaxSpeedMultiplier();
|
||||||
if (yacht.getPowerUp() != null) {
|
if (yacht.getPowerUp() != null) {
|
||||||
if (yacht.getPowerUp().equals(TokenType.BOOST)) {
|
if (yacht.getPowerUp().equals(TokenType.BOOST)) {
|
||||||
// TODO: 11/09/17 wmu16 CHANGE THIS TO MAGIC NUMBER
|
// TODO: 11/09/17 wmu16 CHANGE THIS TO MAGIC NUMBER
|
||||||
@@ -487,17 +487,17 @@ public class GameState implements Runnable {
|
|||||||
// TODO: 15/08/17 remove magic numbers from these equations.
|
// TODO: 15/08/17 remove magic numbers from these equations.
|
||||||
if (yacht.getSailIn()) {
|
if (yacht.getSailIn()) {
|
||||||
if (currentVelocity < maxBoatSpeed - 500) {
|
if (currentVelocity < maxBoatSpeed - 500) {
|
||||||
yacht.changeVelocity(maxBoatSpeed / 100);
|
yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAccelerationMultiplier());
|
||||||
} else if (currentVelocity > maxBoatSpeed + 500) {
|
} else if (currentVelocity > maxBoatSpeed + 500) {
|
||||||
yacht.changeVelocity(-currentVelocity / 200);
|
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
|
||||||
} else {
|
} else {
|
||||||
yacht.setCurrentVelocity(maxBoatSpeed);
|
yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAccelerationMultiplier());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentVelocity > 3000) {
|
if (currentVelocity > 3000) {
|
||||||
yacht.changeVelocity(-currentVelocity / 200);
|
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
|
||||||
} else if (currentVelocity > 100) {
|
} else if (currentVelocity > 100) {
|
||||||
yacht.changeVelocity(-currentVelocity / 50);
|
yacht.changeVelocity((-currentVelocity / 50) * yacht.getAccelerationMultiplier());
|
||||||
} else if (currentVelocity <= 100) {
|
} else if (currentVelocity <= 100) {
|
||||||
yacht.setCurrentVelocity(0d);
|
yacht.setCurrentVelocity(0d);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ import seng302.model.token.TokenType;
|
|||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||||
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
||||||
@@ -20,10 +26,12 @@ public class ServerYacht {
|
|||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(ServerYacht.class);
|
private Logger logger = LoggerFactory.getLogger(ServerYacht.class);
|
||||||
|
|
||||||
public static final Double TURN_STEP = 5.0;
|
|
||||||
|
|
||||||
//Boat info
|
//Boat info
|
||||||
private BoatMeshType boatType;
|
private BoatMeshType boatType;
|
||||||
|
private Double turnStep = 5.0;
|
||||||
|
private Double maxSpeedMultiplier = 1.0;
|
||||||
|
private Double turnStepMultiplier = 1.0;
|
||||||
|
private Double accelerationMultiplier = 1.0;
|
||||||
private Integer sourceId;
|
private Integer sourceId;
|
||||||
private String hullID; //matches HullNum in the XML spec.
|
private String hullID; //matches HullNum in the XML spec.
|
||||||
private String shortName;
|
private String shortName;
|
||||||
@@ -59,7 +67,7 @@ public class ServerYacht {
|
|||||||
|
|
||||||
public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
||||||
String boatName, String country) {
|
String boatName, String country) {
|
||||||
this.boatType = boatType;
|
setBoatType(boatType);
|
||||||
this.boatStatus = BoatStatus.PRESTART;
|
this.boatStatus = BoatStatus.PRESTART;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
this.hullID = hullID;
|
this.hullID = hullID;
|
||||||
@@ -131,7 +139,7 @@ public class ServerYacht {
|
|||||||
* @param amount the amount by which to adjust the boat heading.
|
* @param amount the amount by which to adjust the boat heading.
|
||||||
*/
|
*/
|
||||||
public void adjustHeading(Double amount) {
|
public void adjustHeading(Double amount) {
|
||||||
Double newVal = heading + amount;
|
Double newVal = heading + (amount * turnStepMultiplier);
|
||||||
lastHeading = heading;
|
lastHeading = heading;
|
||||||
heading = (double) Math.floorMod(newVal.longValue(), 360L);
|
heading = (double) Math.floorMod(newVal.longValue(), 360L);
|
||||||
}
|
}
|
||||||
@@ -176,7 +184,7 @@ public class ServerYacht {
|
|||||||
if (isAuto) {
|
if (isAuto) {
|
||||||
turnTowardsHeading(autoHeading);
|
turnTowardsHeading(autoHeading);
|
||||||
if (Math.abs(heading - autoHeading)
|
if (Math.abs(heading - autoHeading)
|
||||||
<= TURN_STEP) { //Cancel when within 1 turn step of target.
|
<= turnStep) { //Cancel when within 1 turn step of target.
|
||||||
isAuto = false;
|
isAuto = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,52 +197,44 @@ public class ServerYacht {
|
|||||||
public void turnUpwind() {
|
public void turnUpwind() {
|
||||||
disableAutoPilot();
|
disableAutoPilot();
|
||||||
Double normalizedHeading = normalizeHeading();
|
Double normalizedHeading = normalizeHeading();
|
||||||
if (continuouslyTurning) {
|
|
||||||
adjustHeading(TURN_STEP);
|
|
||||||
} else {
|
|
||||||
if (normalizedHeading == 0) {
|
if (normalizedHeading == 0) {
|
||||||
if (lastHeading < 180) {
|
if (lastHeading < 180) {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
}
|
}
|
||||||
} else if (normalizedHeading == 180) {
|
} else if (normalizedHeading == 180) {
|
||||||
if (lastHeading < 180) {
|
if (lastHeading < 180) {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
}
|
}
|
||||||
} else if (normalizedHeading < 180) {
|
} else if (normalizedHeading < 180) {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnDownwind() {
|
public void turnDownwind() {
|
||||||
disableAutoPilot();
|
disableAutoPilot();
|
||||||
Double normalizedHeading = normalizeHeading();
|
Double normalizedHeading = normalizeHeading();
|
||||||
if (continuouslyTurning) {
|
|
||||||
adjustHeading(-TURN_STEP);
|
|
||||||
} else {
|
|
||||||
if (normalizedHeading == 0) {
|
if (normalizedHeading == 0) {
|
||||||
if (lastHeading < 180) {
|
if (lastHeading < 180) {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
}
|
}
|
||||||
} else if (normalizedHeading == 180) {
|
} else if (normalizedHeading == 180) {
|
||||||
if (lastHeading < 180) {
|
if (lastHeading < 180) {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
}
|
}
|
||||||
} else if (normalizedHeading < 180) {
|
} else if (normalizedHeading < 180) {
|
||||||
adjustHeading(TURN_STEP);
|
adjustHeading(turnStep);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(-TURN_STEP);
|
adjustHeading(-turnStep);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +278,9 @@ public class ServerYacht {
|
|||||||
private void turnTowardsHeading(Double newHeading) {
|
private void turnTowardsHeading(Double newHeading) {
|
||||||
Double newVal = heading - newHeading;
|
Double newVal = heading - newHeading;
|
||||||
if (Math.floorMod(newVal.longValue(), 360L) > 180) {
|
if (Math.floorMod(newVal.longValue(), 360L) > 180) {
|
||||||
adjustHeading(TURN_STEP / 5);
|
adjustHeading(turnStep / 5);
|
||||||
} else {
|
} else {
|
||||||
adjustHeading(-TURN_STEP / 5);
|
adjustHeading(-turnStep / 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,9 +432,21 @@ public class ServerYacht {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBoatType(BoatMeshType boatType) {
|
public void setBoatType(BoatMeshType boatType) {
|
||||||
|
this.accelerationMultiplier = boatType.accelerationMultiplier;
|
||||||
|
this.maxSpeedMultiplier = boatType.maxSpeedMultiplier;
|
||||||
|
this.turnStepMultiplier = boatType.turnStep;
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Double getMaxSpeedMultiplier() {
|
||||||
|
return maxSpeedMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAccelerationMultiplier(){
|
||||||
|
return accelerationMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BoatMeshType getBoatType() {
|
public BoatMeshType getBoatType() {
|
||||||
return boatType;
|
return boatType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ public class Sounds {
|
|||||||
private static MediaPlayer soundEffect;
|
private static MediaPlayer soundEffect;
|
||||||
private static MediaPlayer soundPlayer;
|
private static MediaPlayer soundPlayer;
|
||||||
private static MediaPlayer hoverSoundPlayer;
|
private static MediaPlayer hoverSoundPlayer;
|
||||||
|
private static MediaPlayer crashSoundPlayer;
|
||||||
|
|
||||||
private static boolean hoverInitialized = false;
|
private static boolean hoverInitialized = false;
|
||||||
|
private static boolean crashInitialized = false;
|
||||||
private static boolean musicMuted = false;
|
private static boolean musicMuted = false;
|
||||||
private static boolean soundEffectsMuted = false;
|
private static boolean soundEffectsMuted = false;
|
||||||
|
|
||||||
@@ -155,11 +157,17 @@ public class Sounds {
|
|||||||
|
|
||||||
public static void playCrashSound() {
|
public static void playCrashSound() {
|
||||||
if (!soundEffectsMuted) {
|
if (!soundEffectsMuted) {
|
||||||
Media crashSound = new Media(
|
if (!crashInitialized) {
|
||||||
|
Media pickupSound = new Media(
|
||||||
Sounds.class.getClassLoader().getResource("sounds/Large-metal-door-slam.mp3")
|
Sounds.class.getClassLoader().getResource("sounds/Large-metal-door-slam.mp3")
|
||||||
.toString());
|
.toString());
|
||||||
soundPlayer = new MediaPlayer(crashSound);
|
crashSoundPlayer = new MediaPlayer(pickupSound);
|
||||||
soundPlayer.play();
|
crashInitialized = true;
|
||||||
|
}
|
||||||
|
if (crashSoundPlayer != null) {
|
||||||
|
crashSoundPlayer.stop();
|
||||||
|
}
|
||||||
|
crashSoundPlayer.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,10 +184,10 @@ public class Sounds {
|
|||||||
public static void playHoverSound() {
|
public static void playHoverSound() {
|
||||||
if (!soundEffectsMuted) {
|
if (!soundEffectsMuted) {
|
||||||
if (!hoverInitialized) {
|
if (!hoverInitialized) {
|
||||||
Media crashSound = new Media(
|
Media hoverSound = new Media(
|
||||||
Sounds.class.getClassLoader().getResource("sounds/Error-sound-effect.mp3")
|
Sounds.class.getClassLoader().getResource("sounds/Error-sound-effect.mp3")
|
||||||
.toString());
|
.toString());
|
||||||
hoverSoundPlayer = new MediaPlayer(crashSound);
|
hoverSoundPlayer = new MediaPlayer(hoverSound);
|
||||||
hoverInitialized = true;
|
hoverInitialized = true;
|
||||||
}
|
}
|
||||||
hoverSoundPlayer.setVolume(0.5);
|
hoverSoundPlayer.setVolume(0.5);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class LobbyController implements Initializable {
|
|||||||
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
|
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
|
||||||
.getBoatName());
|
.getBoatName());
|
||||||
controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
|
controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
|
||||||
.getBoatType());
|
.getBoatType().toString());
|
||||||
|
|
||||||
return customizationDialog;
|
return customizationDialog;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import javafx.fxml.Initializable;
|
|||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.PointLight;
|
import javafx.scene.PointLight;
|
||||||
|
import javafx.scene.control.ProgressBar;
|
||||||
import javafx.scene.layout.Background;
|
import javafx.scene.layout.Background;
|
||||||
import javafx.scene.layout.BackgroundFill;
|
import javafx.scene.layout.BackgroundFill;
|
||||||
import javafx.scene.layout.CornerRadii;
|
import javafx.scene.layout.CornerRadii;
|
||||||
@@ -33,6 +34,12 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
@FXML
|
@FXML
|
||||||
private JFXColorPicker colorPicker;
|
private JFXColorPicker colorPicker;
|
||||||
@FXML
|
@FXML
|
||||||
|
private ProgressBar speedBar;
|
||||||
|
@FXML
|
||||||
|
private ProgressBar accelBar;
|
||||||
|
@FXML
|
||||||
|
private ProgressBar handleBar;
|
||||||
|
@FXML
|
||||||
private JFXButton submitBtn;
|
private JFXButton submitBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private JFXTextField boatName;
|
private JFXTextField boatName;
|
||||||
@@ -47,12 +54,15 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
private ClientToServerThread socketThread;
|
private ClientToServerThread socketThread;
|
||||||
private LobbyController lobbyController;
|
private LobbyController lobbyController;
|
||||||
private BoatMeshType currentBoat;
|
private BoatMeshType currentBoat;
|
||||||
|
private Double maxSpeedMultiplier = 1.0;
|
||||||
|
private Double maxTurnRateMultiplier = 1.0;
|
||||||
|
private Double maxAccelerationMultiplier = 1.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
|
||||||
socketThread = ViewManager.getInstance().getGameClient().getServerThread();
|
socketThread = ViewManager.getInstance().getGameClient().getServerThread();
|
||||||
|
findMaxStats();
|
||||||
RequiredFieldValidator playerNameReqValidator = new RequiredFieldValidator();
|
RequiredFieldValidator playerNameReqValidator = new RequiredFieldValidator();
|
||||||
playerNameReqValidator.setMessage("Player name required.");
|
playerNameReqValidator.setMessage("Player name required.");
|
||||||
|
|
||||||
@@ -111,19 +121,23 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
this.lobbyController = lobbyController;
|
this.lobbyController = lobbyController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentBoat(BoatMeshType boatType) {
|
public void setCurrentBoat(String boatType) {
|
||||||
currentBoat = boatType;
|
currentBoat = BoatMeshType.valueOf(boatType);
|
||||||
displayCurrentBoat();
|
displayCurrentBoat();
|
||||||
|
refreshStatBars(currentBoat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextBoat() {
|
public void nextBoat() {
|
||||||
currentBoat = BoatMeshType.getNextBoatType(currentBoat);
|
currentBoat = BoatMeshType.getNextBoatType(currentBoat);
|
||||||
displayCurrentBoat();
|
displayCurrentBoat();
|
||||||
|
refreshStatBars(currentBoat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prevBoat() {
|
public void prevBoat() {
|
||||||
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
||||||
displayCurrentBoat();
|
displayCurrentBoat();
|
||||||
|
refreshStatBars(currentBoat);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayCurrentBoat() {
|
private void displayCurrentBoat() {
|
||||||
@@ -141,5 +155,26 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
boatPane.getChildren().add(group);
|
boatPane.getChildren().add(group);
|
||||||
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
||||||
group.getChildren().add(bo.getAssets());
|
group.getChildren().add(bo.getAssets());
|
||||||
|
refreshStatBars(currentBoat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findMaxStats() {
|
||||||
|
for (BoatMeshType bmt: BoatMeshType.values()) {
|
||||||
|
if (bmt.turnStep > maxTurnRateMultiplier) {
|
||||||
|
maxTurnRateMultiplier = bmt.turnStep;
|
||||||
|
}
|
||||||
|
if (bmt.maxSpeedMultiplier > maxSpeedMultiplier) {
|
||||||
|
maxSpeedMultiplier = bmt.maxSpeedMultiplier;
|
||||||
|
}
|
||||||
|
if (bmt.accelerationMultiplier > maxAccelerationMultiplier) {
|
||||||
|
maxAccelerationMultiplier = bmt.accelerationMultiplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshStatBars(BoatMeshType bo) {
|
||||||
|
speedBar.setProgress((bo.maxSpeedMultiplier) / maxSpeedMultiplier);
|
||||||
|
accelBar.setProgress(bo.accelerationMultiplier / maxAccelerationMultiplier);
|
||||||
|
handleBar.setProgress(bo.turnStep / maxTurnRateMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,22 @@ package seng302.visualiser.fxObjects.assets_3D;
|
|||||||
*/
|
*/
|
||||||
public enum BoatMeshType {
|
public enum BoatMeshType {
|
||||||
|
|
||||||
DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false),
|
DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false, 1.8, 1.0, 1.0),
|
||||||
CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl",
|
CATAMARAN("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl",
|
||||||
0.997, null, false),
|
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);
|
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 1.2);
|
||||||
|
|
||||||
final String hullFile, mastFile, sailFile, jibFile;
|
final String hullFile, mastFile, sailFile, jibFile;
|
||||||
final double mastOffset, sailOffset;
|
final double mastOffset, sailOffset;
|
||||||
|
public final double maxSpeedMultiplier;
|
||||||
|
public final double accelerationMultiplier;
|
||||||
|
public final double turnStep;
|
||||||
final boolean fixedSail;
|
final boolean fixedSail;
|
||||||
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CAT_ATE_A_MERINGUE, PIRATE_SHIP};
|
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CATAMARAN, PIRATE_SHIP};
|
||||||
|
|
||||||
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 sailOffset, String jibFile, boolean fixedSail, double maxSpeedMultiplier, double accelerationMultiplier, double turnStep) {
|
||||||
this.hullFile = hullFile;
|
this.hullFile = hullFile;
|
||||||
this.mastFile = mastFile;
|
this.mastFile = mastFile;
|
||||||
this.mastOffset = mastOffset;
|
this.mastOffset = mastOffset;
|
||||||
@@ -27,10 +30,12 @@ public enum BoatMeshType {
|
|||||||
this.sailOffset = sailOffset;
|
this.sailOffset = sailOffset;
|
||||||
this.jibFile = jibFile;
|
this.jibFile = jibFile;
|
||||||
this.fixedSail = fixedSail;
|
this.fixedSail = fixedSail;
|
||||||
|
this.maxSpeedMultiplier = maxSpeedMultiplier;
|
||||||
|
this.accelerationMultiplier = accelerationMultiplier;
|
||||||
|
this.turnStep = turnStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO kre39 make something not terrible to cycle through boat types
|
|
||||||
public static BoatMeshType getNextBoatType(BoatMeshType boatType) {
|
public static BoatMeshType getNextBoatType(BoatMeshType boatType) {
|
||||||
for (int i = 0; i < boatTypes.length; i++) {
|
for (int i = 0; i < boatTypes.length; i++) {
|
||||||
if (i == boatTypes.length -1) {
|
if (i == boatTypes.length -1) {
|
||||||
|
|||||||
@@ -71,4 +71,8 @@ public class BoatModel extends Model {
|
|||||||
private MeshView getMeshViewChild(int index) {
|
private MeshView getMeshViewChild(int index) {
|
||||||
return (MeshView) assets.getChildren().get(index);
|
return (MeshView) assets.getChildren().get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BoatMeshType getMeshType() {
|
||||||
|
return meshType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
<?import com.jfoenix.controls.*?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="90.0" minHeight="48.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="90.0" minHeight="48.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="207.0" minHeight="93.0" prefHeight="181.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="207.0" minHeight="93.0" prefHeight="181.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="207.0" minHeight="93.0" prefHeight="181.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="145.0" minHeight="66.0" prefHeight="109.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="145.0" minHeight="66.0" prefHeight="109.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="125.0" minHeight="24.0" prefHeight="72.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="125.0" minHeight="24.0" prefHeight="72.0" vgrow="SOMETIMES" />
|
||||||
@@ -31,12 +33,12 @@
|
|||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="hostDialogHeader" text="Customize Boat" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
<Label fx:id="hostDialogHeader" text="Customize Boat" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
||||||
<JFXButton fx:id="submitBtn" prefHeight="45.0" prefWidth="220.0" text="Customize Boat" GridPane.halignment="CENTER" GridPane.rowIndex="4" GridPane.valignment="CENTER" />
|
<JFXButton fx:id="submitBtn" prefHeight="45.0" prefWidth="220.0" text="Customize Boat" GridPane.halignment="CENTER" GridPane.rowIndex="5" GridPane.valignment="CENTER" />
|
||||||
<JFXTextField fx:id="boatName" focusColor="#6c6c6c" promptText="Boat Name" unFocusColor="#6b6b6b" GridPane.rowIndex="2">
|
<JFXTextField fx:id="boatName" focusColor="#6c6c6c" promptText="Boat Name" unFocusColor="#6b6b6b" GridPane.rowIndex="3">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets left="30.0" right="30.0" />
|
<Insets left="30.0" right="30.0" />
|
||||||
</GridPane.margin></JFXTextField>
|
</GridPane.margin></JFXTextField>
|
||||||
<GridPane GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER">
|
<GridPane GridPane.halignment="CENTER" GridPane.rowIndex="4" GridPane.valignment="CENTER">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="139.0" minWidth="10.0" prefWidth="94.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="139.0" minWidth="10.0" prefWidth="94.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="203.0" minWidth="10.0" prefWidth="198.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="203.0" minWidth="10.0" prefWidth="198.0" />
|
||||||
@@ -75,6 +77,25 @@
|
|||||||
<JFXButton buttonType="RAISED" onAction="#nextBoat" prefHeight="200.0" prefWidth="50.0" text=">" GridPane.columnIndex="2" />
|
<JFXButton buttonType="RAISED" onAction="#nextBoat" prefHeight="200.0" prefWidth="50.0" text=">" GridPane.columnIndex="2" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<GridPane GridPane.rowIndex="2">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Max Speed:" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Acceleration:" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Handling:" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" />
|
||||||
|
<ProgressBar fx:id="speedBar" focusTraversable="false" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1" />
|
||||||
|
<ProgressBar fx:id="accelBar" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<ProgressBar fx:id="handleBar" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ public class BoatMeshTypeTest {
|
|||||||
public void testNextBoatMeshType() {
|
public void testNextBoatMeshType() {
|
||||||
BoatMeshType currentBoat = BoatMeshType.DINGHY;
|
BoatMeshType currentBoat = BoatMeshType.DINGHY;
|
||||||
BoatMeshType nextBoat = BoatMeshType.getNextBoatType(currentBoat);
|
BoatMeshType nextBoat = BoatMeshType.getNextBoatType(currentBoat);
|
||||||
Assert.assertEquals(BoatMeshType.CAT_ATE_A_MERINGUE, nextBoat);
|
Assert.assertEquals(BoatMeshType.CATAMARAN, nextBoat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreviousBoatMeshType() {
|
public void testPreviousBoatMeshType() {
|
||||||
BoatMeshType currentBoat = BoatMeshType.CAT_ATE_A_MERINGUE;
|
BoatMeshType currentBoat = BoatMeshType.CATAMARAN;
|
||||||
BoatMeshType prevBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
BoatMeshType prevBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
||||||
Assert.assertEquals(BoatMeshType.DINGHY, prevBoat);
|
Assert.assertEquals(BoatMeshType.DINGHY, prevBoat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import seng302.model.ServerYacht;
|
|||||||
import seng302.visualiser.ClientToServerThread;
|
import seng302.visualiser.ClientToServerThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Created by kre39 on 7/08/17.
|
* Created by kre39 on 7/08/17.
|
||||||
*/
|
*/
|
||||||
public class ToggleSailSteps {
|
public class ToggleSailSteps {
|
||||||
|
|||||||
Reference in New Issue
Block a user