mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added 3D element to lobby screen to show the player their boat before the race.
tags: #story[1245]
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
package seng302.visualiser;
|
package seng302.visualiser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -32,13 +42,11 @@ import seng302.utilities.Sounds;
|
|||||||
import seng302.utilities.StreamParser;
|
import seng302.utilities.StreamParser;
|
||||||
import seng302.utilities.XMLGenerator;
|
import seng302.utilities.XMLGenerator;
|
||||||
import seng302.utilities.XMLParser;
|
import seng302.utilities.XMLParser;
|
||||||
import seng302.visualiser.controllers.*;
|
import seng302.visualiser.controllers.FinishScreenViewController;
|
||||||
|
import seng302.visualiser.controllers.LobbyController;
|
||||||
import java.io.IOException;
|
import seng302.visualiser.controllers.LobbyController_old;
|
||||||
import java.text.SimpleDateFormat;
|
import seng302.visualiser.controllers.RaceViewController;
|
||||||
import java.time.ZoneId;
|
import seng302.visualiser.controllers.ViewManager;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a client side instance of a yacht racing game in JavaFX. The game is instantiated
|
* This class is a client side instance of a yacht racing game in JavaFX. The game is instantiated
|
||||||
@@ -293,6 +301,9 @@ public class GameClient {
|
|||||||
clientLobbyList.add(boat.getBoatName())
|
clientLobbyList.add(boat.getBoatName())
|
||||||
);
|
);
|
||||||
raceState.setBoats(allBoatsMap.values());
|
raceState.setBoats(allBoatsMap.values());
|
||||||
|
if (lobbyController != null) {
|
||||||
|
lobbyController.setBoats(allBoatsMap);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RACE_START_STATUS:
|
case RACE_START_STATUS:
|
||||||
@@ -512,4 +523,8 @@ public class GameClient {
|
|||||||
if (server != null) server.terminate();
|
if (server != null) server.terminate();
|
||||||
if (socketThread != null) socketThread.setSocketToClose();
|
if (socketThread != null) socketThread.setSocketToClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Integer, ClientYacht> getAllBoatsMap() {
|
||||||
|
return allBoatsMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package seng302.visualiser.controllers;
|
|||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXDialog;
|
import com.jfoenix.controls.JFXDialog;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -23,6 +21,7 @@ import javafx.scene.layout.VBox;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import seng302.gameServer.GameStages;
|
import seng302.gameServer.GameStages;
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.Colors;
|
import seng302.model.Colors;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
@@ -30,7 +29,6 @@ import seng302.model.mark.CompoundMark;
|
|||||||
import seng302.model.mark.Corner;
|
import seng302.model.mark.Corner;
|
||||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.utilities.XMLGenerator;
|
|
||||||
import seng302.visualiser.GameView;
|
import seng302.visualiser.GameView;
|
||||||
import seng302.visualiser.controllers.cells.PlayerCell;
|
import seng302.visualiser.controllers.cells.PlayerCell;
|
||||||
|
|
||||||
@@ -57,12 +55,15 @@ public class LobbyController implements Initializable {
|
|||||||
private RaceState raceState;
|
private RaceState raceState;
|
||||||
private JFXDialog customizationDialog;
|
private JFXDialog customizationDialog;
|
||||||
public Color playersColor;
|
public Color playersColor;
|
||||||
|
private Map<Integer, ClientYacht> playerBoats;
|
||||||
private Double mapWidth, mapHeight;
|
private Double mapWidth, mapHeight;
|
||||||
private GameView gameView;
|
private GameView gameView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
|
||||||
|
this.playerBoats = ViewManager.getInstance().getGameClient().getAllBoatsMap();
|
||||||
|
|
||||||
if (this.playersColor == null) {
|
if (this.playersColor == null) {
|
||||||
this.playersColor = Colors.getColor(ViewManager.getInstance().getGameClient().getServerThread().getClientId() - 1);
|
this.playersColor = Colors.getColor(ViewManager.getInstance().getGameClient().getServerThread().getClientId() - 1);
|
||||||
}
|
}
|
||||||
@@ -121,6 +122,10 @@ public class LobbyController implements Initializable {
|
|||||||
gameView.updateCourse(marks, corners);
|
gameView.updateCourse(marks, corners);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getPlayerColors() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -162,23 +167,28 @@ public class LobbyController implements Initializable {
|
|||||||
*/
|
*/
|
||||||
private void refreshPlayerList() {
|
private void refreshPlayerList() {
|
||||||
playerListVBox.getChildren().clear();
|
playerListVBox.getChildren().clear();
|
||||||
|
if (this.playerBoats == null || this.playerBoats.size() == 0) {
|
||||||
for (String player : ViewManager.getInstance().getPlayerList()) {
|
this.playerBoats = ViewManager.getInstance().getGameClient().getAllBoatsMap();
|
||||||
|
}
|
||||||
|
// TODO: 12/09/2017 ajm412: Make it so that it only removes players who's details have changed.
|
||||||
|
for (Integer playerId : playerBoats.keySet()) {
|
||||||
VBox pane = null;
|
VBox pane = null;
|
||||||
|
|
||||||
|
ClientYacht yacht = playerBoats.get(playerId);
|
||||||
|
|
||||||
FXMLLoader loader = new FXMLLoader(
|
FXMLLoader loader = new FXMLLoader(
|
||||||
getClass().getResource("/views/cells/PlayerCell.fxml"));
|
getClass().getResource("/views/cells/PlayerCell.fxml"));
|
||||||
|
|
||||||
loader.setController(new PlayerCell(player));
|
loader.setController(new PlayerCell(playerId, yacht.getBoatName(), yacht.getColour()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pane = loader.load();
|
pane = loader.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO replace with logger
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
playerListVBox.getChildren().add(pane);
|
playerListVBox.getChildren().add(pane);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,6 +217,10 @@ public class LobbyController implements Initializable {
|
|||||||
this.beginRaceButton.setText("Starting in: " + raceState.getRaceTimeStr());
|
this.beginRaceButton.setText("Starting in: " + raceState.getRaceTimeStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBoats(Map<Integer, ClientYacht> boats) {
|
||||||
|
this.playerBoats = boats;
|
||||||
|
}
|
||||||
|
|
||||||
public void closeCustomizationDialog() {
|
public void closeCustomizationDialog() {
|
||||||
customizationDialog.close();
|
customizationDialog.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
package seng302.visualiser.controllers.cells;
|
package seng302.visualiser.controllers.cells;
|
||||||
|
|
||||||
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.geometry.Point3D;
|
||||||
|
import javafx.scene.Group;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.effect.DropShadow;
|
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.transform.Rotate;
|
||||||
|
import javafx.scene.transform.Scale;
|
||||||
|
import javafx.scene.transform.Translate;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||||
|
|
||||||
public class PlayerCell {
|
public class PlayerCell {
|
||||||
|
|
||||||
@@ -15,16 +24,61 @@ public class PlayerCell {
|
|||||||
private Label playerName;
|
private Label playerName;
|
||||||
@FXML
|
@FXML
|
||||||
private GridPane playerListCell;
|
private GridPane playerListCell;
|
||||||
|
@FXML
|
||||||
|
private Pane boatPane;
|
||||||
//---------FXML END---------//
|
//---------FXML END---------//
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
private Integer boatAngle;
|
||||||
|
private Color boatColor;
|
||||||
|
private Integer playerId;
|
||||||
|
|
||||||
public PlayerCell(String playerName) {
|
public PlayerCell(Integer playerId, String playerName, Color color) {
|
||||||
|
this.playerId = playerId;
|
||||||
this.name = playerName;
|
this.name = playerName;
|
||||||
|
this.boatColor = color;
|
||||||
|
this.boatAngle = -45;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
playerName.setText(name);
|
playerName.setText(name);
|
||||||
|
|
||||||
|
Group group = new Group();
|
||||||
|
boatPane.getChildren().add(group);
|
||||||
|
|
||||||
|
BoatModel bo = ModelFactory.boatIconView(BoatMeshType.DINGHY, this.boatColor);
|
||||||
|
bo.showSail();
|
||||||
|
bo.rotateSail(45);
|
||||||
|
bo.getAssets().getTransforms().setAll(
|
||||||
|
new Scale(4, 4, 4),
|
||||||
|
new Translate(12, 14, 0),
|
||||||
|
new Rotate(270, new Point3D(1, 0, 0)),
|
||||||
|
new Rotate(-45, new Point3D(0, 0, 1))
|
||||||
|
);
|
||||||
|
|
||||||
|
bo.setAnimation(new AnimationTimer() {
|
||||||
|
Group group = bo.getAssets();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(long now) {
|
||||||
|
((Rotate) group.getTransforms().get(3)).setAngle(boatAngle++);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
group.getChildren().add(bo.getAssets());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPlayerId() {
|
||||||
|
return playerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getBoatColor() {
|
||||||
|
return boatColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playButtonHoverSound(MouseEvent mouseEvent) {
|
public void playButtonHoverSound(MouseEvent mouseEvent) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAnimation(AnimationTimer animation) {
|
public void setAnimation(AnimationTimer animation) {
|
||||||
animationTimer = animation;
|
animationTimer = animation;
|
||||||
if (animation != null) {
|
if (animation != null) {
|
||||||
animation.start();
|
animation.start();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#playerName {
|
#playerName {
|
||||||
-fx-text-fill: -fx-pp-dark-text-color;
|
-fx-text-fill: -fx-pp-light-text-color;
|
||||||
-fx-font-size: 18px;
|
-fx-font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#playerListCell {
|
#playerListCell {
|
||||||
-fx-background-color: -fx-pp-front-color;
|
-fx-background-color: skyblue;
|
||||||
-fx-effect: -fx-pp-dropshadow-light;
|
-fx-effect: -fx-pp-dropshadow-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.*?>
|
<?import java.lang.String?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
<VBox fx:id="playerCellVBox" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
|
<VBox fx:id="playerCellVBox" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
|
||||||
minHeight="-Infinity" minWidth="-Infinity" prefHeight="80.0" xmlns="http://javafx.com/javafx/8"
|
minHeight="-Infinity" minWidth="-Infinity" prefHeight="80.0"
|
||||||
xmlns:fx="http://javafx.com/fxml/1">
|
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<String fx:value="/css/master.css" />
|
<String fx:value="/css/master.css" />
|
||||||
<String fx:value="/css/cells/PlayerCell.css"/>
|
<String fx:value="/css/cells/PlayerCell.css"/>
|
||||||
@@ -18,17 +19,19 @@
|
|||||||
<GridPane fx:id="playerListCell" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
|
<GridPane fx:id="playerListCell" maxHeight="-Infinity" maxWidth="1.7976931348623157E308"
|
||||||
minHeight="-Infinity" prefHeight="70.0">
|
minHeight="-Infinity" prefHeight="70.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="355.0" minWidth="355.0"
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="80.0" minWidth="80.0" prefWidth="80.0"/>
|
||||||
prefWidth="355.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="290.0" minWidth="290.0"
|
||||||
|
prefWidth="290.0"/>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="80.0" minHeight="80.0" prefHeight="80.0" vgrow="SOMETIMES"/>
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="playerName" text="Party parrots in space">
|
<Label fx:id="playerName" text="Party parrots in space" GridPane.columnIndex="1">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets left="20.0" />
|
<Insets left="20.0" />
|
||||||
</padding></Label>
|
</padding></Label>
|
||||||
|
<Pane fx:id="boatPane" prefHeight="200.0" prefWidth="200.0"/>
|
||||||
</children>
|
</children>
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets right="40.0"/>
|
<Insets right="40.0"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user