Completed working boat selection screen.

When a user selects a different boat, it is sent to all other clients and updates accordingly. Boats are all shown with their correct models in game.

#story[1274]
This commit is contained in:
Kusal Ekanayake
2017-09-20 20:46:23 +12:00
parent 7d8a6afa5f
commit 307e79ecfc
12 changed files with 114 additions and 17 deletions
@@ -130,7 +130,8 @@ public class LobbyController implements Initializable {
controller.setPlayerName(this.playerBoats
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatName());
controller.setCurrentBoat(BoatMeshType.DINGHY);
controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatType());
return customizationDialog;
}
@@ -204,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()));
loader.setController(new PlayerCell(playerId, yacht.getBoatName(), yacht.getColour(), yacht.getBoatType()));
try {
pane = loader.load();
@@ -278,6 +278,8 @@ public class ViewManager {
stage.setMinHeight(500);
stage.setMinWidth(800);
stage.setTitle("Party Parrots At Sea");
stage.getIcons().add(new Image(getClass().getResourceAsStream("/PP.png")));
stage.setOnCloseRequest(e -> closeAll());
stage.setScene(scene);
stage.show();
@@ -24,11 +24,13 @@ public class PlayerCell {
private String name;
private Color boatColor;
private Integer playerId;
private BoatMeshType boatype;
public PlayerCell(Integer playerId, String playerName, Color color) {
public PlayerCell(Integer playerId, String playerName, Color color, String boatType) {
this.playerId = playerId;
this.name = playerName;
this.boatColor = color;
this.boatype = BoatMeshType.getBoatMeshType(boatType);
}
public void initialize() {
@@ -37,7 +39,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(BoatMeshType.PIRATE_SHIP, this.boatColor);
BoatModel bo = ModelFactory.boatIconView(this.boatype, this.boatColor);
group.getChildren().add(bo.getAssets());
}
@@ -11,6 +11,7 @@ import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.PointLight;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
@@ -111,21 +112,35 @@ public class BoatCustomizeController implements Initializable{
this.lobbyController = lobbyController;
}
public void setCurrentBoat(BoatMeshType boatType) {
public void setCurrentBoat(String boatType) {
Group group = new Group();
this.currentBoat = boatType;
this.currentBoat = BoatMeshType.getBoatMeshType(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());
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
group.getChildren().add(new PointLight());
}
public void nextBoat(ActionEvent actionEvent) {
boatPane.getChildren().clear();
Group group = new Group();
boatPane.getChildren().add(group);
currentBoat = BoatMeshType.getNextBoatType(currentBoat);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
group.getChildren().add(new PointLight());
}
public void prevBoat(ActionEvent actionEvent) {
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());
}
private void RefreshBoat() {