mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Started working on the boat selection screen.
Customised the boat customisation UI to contain it. Need to have another boat to test whether we can switch boats and also if the messages get sent correctly. #story[1274]
This commit is contained in:
@@ -702,6 +702,9 @@ public class GameState implements Runnable {
|
||||
int blue = customizeData[2] & 0xFF;
|
||||
Color yachtColor = Color.rgb(red, green, blue);
|
||||
playerYacht.setBoatColor(yachtColor);
|
||||
} else if (requestType.equals(CustomizeRequestType.SHAPE)) {
|
||||
String type = new String(customizeData);
|
||||
playerYacht.setBoatType(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ServerToClientThread implements Runnable {
|
||||
lName = all.get(ThreadLocalRandom.current().nextInt(0, all.size()));
|
||||
|
||||
ServerYacht yacht = new ServerYacht(
|
||||
"Yacht", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||
"DINGHY", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||
);
|
||||
|
||||
player = new Player(socket, yacht);
|
||||
|
||||
@@ -421,4 +421,7 @@ public class ServerYacht {
|
||||
return boatColor;
|
||||
}
|
||||
|
||||
public void setBoatType(String boatType) {
|
||||
this.boatType = boatType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
|
||||
public class LobbyController implements Initializable {
|
||||
|
||||
@@ -129,6 +130,7 @@ public class LobbyController implements Initializable {
|
||||
controller.setPlayerName(this.playerBoats
|
||||
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
|
||||
.getBoatName());
|
||||
controller.setCurrentBoat(BoatMeshType.DINGHY);
|
||||
|
||||
return customizationDialog;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,21 @@ import java.util.ResourceBundle;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.layout.CornerRadii;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import seng302.gameServer.messages.CustomizeRequestType;
|
||||
import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.ClientToServerThread;
|
||||
import seng302.visualiser.controllers.LobbyController;
|
||||
import seng302.visualiser.controllers.ViewManager;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
import seng302.visualiser.validators.FieldLengthValidator;
|
||||
import seng302.visualiser.validators.ValidationTools;
|
||||
|
||||
@@ -28,13 +37,17 @@ public class BoatCustomizeController implements Initializable{
|
||||
@FXML
|
||||
private JFXTextField boatName;
|
||||
@FXML
|
||||
private Pane boatPane;
|
||||
@FXML
|
||||
void colorChanged(ActionEvent event) {
|
||||
Color color = colorPicker.getValue();
|
||||
RefreshBoat();
|
||||
}
|
||||
//---------FXML END---------//
|
||||
|
||||
private ClientToServerThread socketThread;
|
||||
private LobbyController lobbyController;
|
||||
private BoatMeshType currentBoat;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
@@ -55,6 +68,7 @@ public class BoatCustomizeController implements Initializable{
|
||||
});
|
||||
|
||||
submitBtn.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +92,10 @@ public class BoatCustomizeController implements Initializable{
|
||||
colorArray[2] = (byte) blue;
|
||||
|
||||
socketThread.sendCustomizationRequest(CustomizeRequestType.COLOR, colorArray);
|
||||
socketThread.sendCustomizationRequest(CustomizeRequestType.SHAPE, currentBoat.toString().getBytes());
|
||||
lobbyController.closeCustomizationDialog();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,4 +110,29 @@ public class BoatCustomizeController implements Initializable{
|
||||
public void setParentController(LobbyController lobbyController){
|
||||
this.lobbyController = lobbyController;
|
||||
}
|
||||
|
||||
public void setCurrentBoat(BoatMeshType boatType) {
|
||||
Group group = new Group();
|
||||
this.currentBoat = boatType;
|
||||
System.out.println(boatType.toString());
|
||||
boatPane.setBackground(new Background(new BackgroundFill(Color.SKYBLUE, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
boatPane.getChildren().add(group);
|
||||
BoatModel bo = ModelFactory.boatCustomiseView(boatType, colorPicker.getValue());
|
||||
group.getChildren().add(bo.getAssets());
|
||||
}
|
||||
|
||||
public void nextBoat(ActionEvent actionEvent) {
|
||||
boatPane.getChildren().clear();
|
||||
}
|
||||
|
||||
public void prevBoat(ActionEvent actionEvent) {
|
||||
}
|
||||
|
||||
private void RefreshBoat() {
|
||||
boatPane.getChildren().clear();
|
||||
Group group = new Group();
|
||||
boatPane.getChildren().add(group);
|
||||
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
|
||||
group.getChildren().add(bo.getAssets());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,35 @@ public class ModelFactory {
|
||||
return bo;
|
||||
}
|
||||
|
||||
public static BoatModel boatCustomiseView(BoatMeshType boatType, Color primaryColour) {
|
||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||
final Rotate animationRotate = new Rotate(0, new Point3D(0,0,1));
|
||||
boatAssets.getTransforms().addAll(
|
||||
new Scale(8.0, 8.0, 8.0),
|
||||
new Rotate(-70, new Point3D(1,0,0)),
|
||||
new Translate(16,50, 0),
|
||||
animationRotate
|
||||
);
|
||||
|
||||
boatAssets.getTransforms().add(animationRotate);
|
||||
BoatModel bo = new BoatModel(boatAssets, null, boatType);
|
||||
bo.rotateSail(45);
|
||||
|
||||
bo.setAnimation(new AnimationTimer() {
|
||||
double boatAngle = 0;
|
||||
Rotate rotate = animationRotate;
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
boatAngle += 0.5;
|
||||
rotate.setAngle(boatAngle);
|
||||
}
|
||||
});
|
||||
boatAssets.getChildren().addAll(
|
||||
new AmbientLight()
|
||||
);
|
||||
return bo;
|
||||
}
|
||||
|
||||
public static BoatModel boatRotatingView(BoatMeshType boatType, Color primaryColour) {
|
||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||
boatAssets.getTransforms().addAll(
|
||||
|
||||
Reference in New Issue
Block a user