mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'develop' into Story1274_custom_boat_stats
# Conflicts: # src/main/java/seng302/model/ServerYacht.java # src/main/java/seng302/visualiser/controllers/dialogs/BoatCustomizeController.java
This commit is contained in:
@@ -18,6 +18,7 @@ import seng302.utilities.XMLParser;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.util.*;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
|
||||
/**
|
||||
* A Static class to hold information about the current state of the game (model)
|
||||
@@ -704,7 +705,7 @@ public class GameState implements Runnable {
|
||||
playerYacht.setBoatColor(yachtColor);
|
||||
} else if (requestType.equals(CustomizeRequestType.SHAPE)) {
|
||||
String type = new String(customizeData);
|
||||
playerYacht.setBoatType(type);
|
||||
playerYacht.setBoatType(BoatMeshType.valueOf(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import seng302.model.stream.packets.PacketType;
|
||||
import seng302.model.stream.packets.StreamPacket;
|
||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
||||
import seng302.utilities.XMLGenerator;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
|
||||
/**
|
||||
* A class describing a single connection to a Client for the purposes of sending and receiving on
|
||||
@@ -125,7 +126,7 @@ public class ServerToClientThread implements Runnable {
|
||||
lName = all.get(ThreadLocalRandom.current().nextInt(0, all.size()));
|
||||
|
||||
ServerYacht yacht = new ServerYacht(
|
||||
"DINGHY", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||
BoatMeshType.DINGHY, sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||
);
|
||||
|
||||
player = new Player(socket, yacht);
|
||||
|
||||
@@ -15,6 +15,7 @@ import javafx.beans.property.ReadOnlyLongWrapper;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
|
||||
/**
|
||||
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||
@@ -37,7 +38,7 @@ public class ClientYacht extends Observable {
|
||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||
|
||||
|
||||
private String boatType;
|
||||
private BoatMeshType boatType;
|
||||
private Integer sourceId;
|
||||
private String hullID; //matches HullNum in the XML spec.
|
||||
private String shortName;
|
||||
@@ -64,7 +65,7 @@ public class ClientYacht extends Observable {
|
||||
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
|
||||
private Color colour;
|
||||
|
||||
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
public ClientYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
||||
String boatName, String country) {
|
||||
this.boatType = boatType;
|
||||
this.sourceId = sourceId;
|
||||
@@ -88,7 +89,7 @@ public class ClientYacht extends Observable {
|
||||
super.addObserver(o);
|
||||
}
|
||||
|
||||
public String getBoatType() {
|
||||
public BoatMeshType getBoatType() {
|
||||
return boatType;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ 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)
|
||||
@@ -20,10 +23,10 @@ import java.util.Objects;
|
||||
*/
|
||||
public class ServerYacht {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||
private Logger logger = LoggerFactory.getLogger(ServerYacht.class);
|
||||
|
||||
//Boat info
|
||||
private String boatType;
|
||||
private BoatMeshType boatType;
|
||||
private Double turnStep = 5.0;
|
||||
private Double maxSpeedMultiplier = 1.0;
|
||||
private Double acceleration = 1.0;
|
||||
@@ -58,7 +61,7 @@ public class ServerYacht {
|
||||
private Long powerUpStartTime;
|
||||
|
||||
|
||||
public ServerYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||
public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
||||
String boatName, String country) {
|
||||
setBoatType(boatType);
|
||||
this.boatStatus = BoatStatus.PRESTART;
|
||||
@@ -422,16 +425,7 @@ public class ServerYacht {
|
||||
return boatColor;
|
||||
}
|
||||
|
||||
public void setBoatType(String boatType) {
|
||||
BoatMeshType boatMeshType;
|
||||
for (BoatMeshType boatMesh: BoatMeshType.values()) {
|
||||
if (Objects.equals(boatType, boatMesh.toString())) {
|
||||
boatMeshType = boatMesh;
|
||||
turnStep = turnStep * boatMeshType.turnStep;
|
||||
maxSpeedMultiplier = boatMeshType.maxSpeedMultiplier;
|
||||
acceleration = boatMeshType.accelerationMultiplier;
|
||||
}
|
||||
}
|
||||
public void setBoatType(BoatMeshType boatType) {
|
||||
this.boatType = boatType;
|
||||
}
|
||||
|
||||
@@ -443,7 +437,8 @@ public class ServerYacht {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public String getBoatType() {
|
||||
|
||||
public BoatMeshType getBoatType() {
|
||||
return boatType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
import seng302.model.stream.xml.parser.RegattaXMLData;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.model.token.TokenType;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
|
||||
/**
|
||||
* Utilities for parsing XML documents
|
||||
@@ -139,7 +140,7 @@ public class XMLParser {
|
||||
if (currentBoat.getNodeName().equals("Boat")) {
|
||||
// Boat boat = new Boat(currentBoat);
|
||||
ClientYacht yacht = new ClientYacht(
|
||||
XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
||||
BoatMeshType.valueOf(XMLParser.getNodeAttributeString(currentBoat, "Type")),
|
||||
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
||||
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
||||
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
||||
|
||||
@@ -460,7 +460,7 @@ public class GameView3D {
|
||||
final List<Group> wakes = new ArrayList<>();
|
||||
for (ClientYacht clientYacht : yachts) {
|
||||
Color colour = clientYacht.getColour();
|
||||
newBoat = new BoatObject(BoatMeshType.getBoatMeshType(clientYacht.getBoatType()));
|
||||
newBoat = new BoatObject(clientYacht.getBoatType());
|
||||
newBoat.setFill(colour);
|
||||
boatObjects.put(clientYacht, newBoat);
|
||||
wakesGroup.getChildren().add(newBoat.getWake());
|
||||
|
||||
@@ -205,7 +205,7 @@ public class LobbyController implements Initializable {
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
getClass().getResource("/views/cells/PlayerCell.fxml"));
|
||||
|
||||
loader.setController(new PlayerCell(playerId, yacht.getBoatName(), yacht.getColour(), yacht.getBoatType()));
|
||||
loader.setController(new PlayerCell(playerId, yacht));
|
||||
|
||||
try {
|
||||
pane = loader.load();
|
||||
|
||||
@@ -6,6 +6,7 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
@@ -24,13 +25,13 @@ public class PlayerCell {
|
||||
private String name;
|
||||
private Color boatColor;
|
||||
private Integer playerId;
|
||||
private BoatMeshType boatype;
|
||||
private BoatMeshType boatType;
|
||||
|
||||
public PlayerCell(Integer playerId, String playerName, Color color, String boatType) {
|
||||
public PlayerCell(Integer playerId, ClientYacht yacht) {
|
||||
this.playerId = playerId;
|
||||
this.name = playerName;
|
||||
this.boatColor = color;
|
||||
this.boatype = BoatMeshType.getBoatMeshType(boatType);
|
||||
this.name = yacht.getBoatName();
|
||||
this.boatColor = yacht.getColour();
|
||||
this.boatType = yacht.getBoatType();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
@@ -39,7 +40,7 @@ public class PlayerCell {
|
||||
// Add Rotating Boat to Player Cell with players color on it.
|
||||
Group group = new Group();
|
||||
boatPane.getChildren().add(group);
|
||||
BoatModel bo = ModelFactory.boatIconView(this.boatype, this.boatColor);
|
||||
BoatModel bo = ModelFactory.boatIconView(boatType, boatColor);
|
||||
group.getChildren().add(bo.getAssets());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.validation.RequiredFieldValidator;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
@@ -47,9 +46,8 @@ public class BoatCustomizeController implements Initializable{
|
||||
@FXML
|
||||
private Pane boatPane;
|
||||
@FXML
|
||||
void colorChanged(ActionEvent event) {
|
||||
Color color = colorPicker.getValue();
|
||||
RefreshBoat();
|
||||
void colorChanged() {
|
||||
refreshBoat();
|
||||
}
|
||||
//---------FXML END---------//
|
||||
|
||||
@@ -72,6 +70,8 @@ public class BoatCustomizeController implements Initializable{
|
||||
playerNameLengthValidator.setMessage("Player name too long.");
|
||||
|
||||
boatName.setValidators(playerNameLengthValidator, playerNameReqValidator);
|
||||
boatPane.setBackground(
|
||||
new Background(new BackgroundFill(Color.SKYBLUE, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
|
||||
submitBtn.setOnMouseReleased(event -> {
|
||||
Sounds.playButtonClick();
|
||||
@@ -79,7 +79,6 @@ public class BoatCustomizeController implements Initializable{
|
||||
});
|
||||
|
||||
submitBtn.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,42 +122,34 @@ public class BoatCustomizeController implements Initializable{
|
||||
}
|
||||
|
||||
public void setCurrentBoat(String boatType) {
|
||||
Group group = new Group();
|
||||
this.currentBoat = BoatMeshType.getBoatMeshType(boatType);
|
||||
boatPane.setBackground(new Background(new BackgroundFill(Color.SKYBLUE, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
boatPane.getChildren().add(group);
|
||||
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
||||
group.getChildren().add(bo.getAssets());
|
||||
group.getChildren().add(new PointLight());
|
||||
refreshStatBars(bo);
|
||||
|
||||
currentBoat = boatType;
|
||||
displayCurrentBoat();
|
||||
refreshStatBars(currentBoat);
|
||||
}
|
||||
|
||||
public void nextBoat(ActionEvent actionEvent) {
|
||||
boatPane.getChildren().clear();
|
||||
Group group = new Group();
|
||||
boatPane.getChildren().add(group);
|
||||
public void nextBoat() {
|
||||
currentBoat = BoatMeshType.getNextBoatType(currentBoat);
|
||||
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
||||
group.getChildren().add(bo.getAssets());
|
||||
group.getChildren().add(new PointLight());
|
||||
refreshStatBars(bo);
|
||||
displayCurrentBoat();
|
||||
refreshStatBars(currentBoat);
|
||||
}
|
||||
|
||||
public void prevBoat() {
|
||||
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
||||
displayCurrentBoat();
|
||||
refreshStatBars(currentBoat);
|
||||
|
||||
}
|
||||
|
||||
public void prevBoat(ActionEvent actionEvent) {
|
||||
private void displayCurrentBoat() {
|
||||
boatPane.getChildren().clear();
|
||||
Group group = new Group();
|
||||
boatPane.getChildren().add(group);
|
||||
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
|
||||
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
||||
group.getChildren().add(bo.getAssets());
|
||||
group.getChildren().add(new PointLight());
|
||||
refreshStatBars(bo);
|
||||
|
||||
}
|
||||
|
||||
private void RefreshBoat() {
|
||||
private void refreshBoat() {
|
||||
boatPane.getChildren().clear();
|
||||
Group group = new Group();
|
||||
boatPane.getChildren().add(group);
|
||||
|
||||
@@ -35,19 +35,6 @@ public enum BoatMeshType {
|
||||
this.turnStep = turnStep;
|
||||
}
|
||||
|
||||
public static BoatMeshType getBoatMeshType(String boatType) {
|
||||
switch (boatType){
|
||||
case "DINGHY":
|
||||
return DINGHY;
|
||||
case "CAT_ATE_A_MERINGUE":
|
||||
return CAT_ATE_A_MERINGUE;
|
||||
case "PIRATE_SHIP":
|
||||
return PIRATE_SHIP;
|
||||
default:
|
||||
return DINGHY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO kre39 make something not terrible to cycle through boat types
|
||||
public static BoatMeshType getNextBoatType(BoatMeshType boatType) {
|
||||
|
||||
Reference in New Issue
Block a user