mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea0be5e952 | |||
| 7197bc2bee | |||
| fba522d0c3 | |||
| 0e829874c2 | |||
| c5d56065b6 | |||
| fe76e85c71 | |||
| 9d61a43bd7 | |||
| c39582de5c | |||
| 9ed52a1225 | |||
| da263355f4 | |||
| ebecd25ed2 | |||
| 0f5137c2b6 | |||
| 73799954e4 | |||
| edfeb2b287 | |||
| 0355784000 |
@@ -323,6 +323,7 @@ public class GameState implements Runnable {
|
||||
if (yacht.getPowerUp() != null) {
|
||||
if (System.currentTimeMillis() - yacht.getPowerUpStartTime() > POWERUP_TIMEOUT_MS) {
|
||||
yacht.powerDown();
|
||||
sendServerMessage(yacht.getSourceId(), yacht.getBoatName() + "'s power-up token expired");
|
||||
logger.debug("Yacht: " + yacht.getShortName() + " powered down!");
|
||||
}
|
||||
}
|
||||
@@ -433,6 +434,7 @@ public class GameState implements Runnable {
|
||||
//Token Collision
|
||||
Token collidedToken = checkTokenPickUp(serverYacht);
|
||||
if (collidedToken != null) {
|
||||
sendServerMessage(serverYacht.getSourceId(), serverYacht.getBoatName() + " has picked speed-up token");
|
||||
tokensInPlay.remove(collidedToken);
|
||||
serverYacht.powerUp(collidedToken.getTokenType());
|
||||
logger.debug("Yacht: " + serverYacht.getShortName() + " got powerup " + collidedToken
|
||||
@@ -531,6 +533,9 @@ public class GameState implements Runnable {
|
||||
}
|
||||
|
||||
if (hasProgressed) {
|
||||
if (currentMarkSeqID != 0 && !markOrder.isLastMark(currentMarkSeqID)) {
|
||||
sendServerMessage(yacht.getSourceId(), yacht.getBoatName() + " passed leg " + yacht.getLegNumber());
|
||||
}
|
||||
yacht.incrementLegNumber();
|
||||
sendMarkRoundingMessage(yacht);
|
||||
logMarkRounding(yacht);
|
||||
@@ -565,6 +570,7 @@ public class GameState implements Runnable {
|
||||
if (crossedLine == 2 && isClockwiseCross || crossedLine == 1 && !isClockwiseCross) {
|
||||
yacht.setClosestCurrentMark(mark1);
|
||||
yacht.setBoatStatus(BoatStatus.RACING);
|
||||
sendServerMessage(yacht.getSourceId(), yacht.getBoatName() + " passed start line");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -668,6 +674,7 @@ public class GameState implements Runnable {
|
||||
if (crossedLine == 1 && isClockwiseCross || crossedLine == 2 && !isClockwiseCross) {
|
||||
yacht.setClosestCurrentMark(mark1);
|
||||
yacht.setBoatStatus(BoatStatus.FINISHED);
|
||||
sendServerMessage(yacht.getSourceId(), yacht.getBoatName() + " passed finish line");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -788,12 +795,7 @@ public class GameState implements Runnable {
|
||||
try {
|
||||
setSpeedMultiplier(Double.valueOf(words[3]));
|
||||
sendServerMessage(chatterMessage.getMessage_type(),
|
||||
"SERVER: Speed modifier set to x" + words[3]);
|
||||
System.out.println(chatterMessage.getMessage_type());
|
||||
// notifyMessageListeners(new ChatterMessage(
|
||||
// chatterMessage.getMessage_type(),
|
||||
// "SERVER: Speed modifier set to x" + words[3]
|
||||
// ));
|
||||
"Speed modifier set to x" + words[3]);
|
||||
} catch (Exception e) {
|
||||
Logger logger = LoggerFactory.getLogger(GameState.class);
|
||||
logger.error("cannot parse >speed value");
|
||||
@@ -801,12 +803,7 @@ public class GameState implements Runnable {
|
||||
return;
|
||||
case "/finish":
|
||||
sendServerMessage(chatterMessage.getMessage_type(),
|
||||
"SERVER: Game will now finish");
|
||||
System.out.println(chatterMessage.getMessage_type());
|
||||
// notifyMessageListeners(new ChatterMessage(
|
||||
// chatterMessage.getMessage_type(),
|
||||
// "SERVER: Game will now finish"
|
||||
// ));
|
||||
"Game will now finish");
|
||||
endRace();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,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.DINGHY, this.boatColor);
|
||||
BoatModel bo = ModelFactory.boatIconView(BoatMeshType.PIRATE_SHIP, this.boatColor);
|
||||
group.getChildren().add(bo.getAssets());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,29 @@ package seng302.visualiser.fxObjects.assets_3D;
|
||||
|
||||
/**
|
||||
* Enum for boat meshes. Enum values should be of the form :
|
||||
* ENUM_VALUE (hull file, mast file, X offset of mast CoR from origin, sail file, X offset of sail CoR from origin)
|
||||
* ENUM_VALUE (hull file, mast file, Y offset of mast CoR from origin, sail file, Y offset of sail CoR from origin, jib file, fixed sail)
|
||||
* Files must be valid .stl files.
|
||||
*/
|
||||
public enum BoatMeshType {
|
||||
|
||||
DINGHY ("dinghy_hull.stl", "dinghy_mast.stl", -1.36653, "dinghy_sail.stl", -1.36653);
|
||||
DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false),
|
||||
CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl",
|
||||
0.997, null, false),
|
||||
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
|
||||
-0.5415, "pirateship_frontsail.stl", true);
|
||||
|
||||
final String hullFile, mastFile, sailFile;
|
||||
final String hullFile, mastFile, sailFile, jibFile;
|
||||
final double mastOffset, sailOffset;
|
||||
final boolean fixedSail;
|
||||
|
||||
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile, double sailOffset) {
|
||||
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile,
|
||||
double sailOffset, String jibFile, boolean fixedSail) {
|
||||
this.hullFile = hullFile;
|
||||
this.mastFile = mastFile;
|
||||
this.mastOffset = mastOffset;
|
||||
this.sailFile = sailFile;
|
||||
this.sailOffset = sailOffset;
|
||||
this.jibFile = jibFile;
|
||||
this.fixedSail = fixedSail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,15 +34,17 @@ public class BoatModel extends Model {
|
||||
* @param degrees The rotation of the sail in degrees
|
||||
*/
|
||||
public void rotateSail(double degrees) {
|
||||
if (!meshType.fixedSail) {
|
||||
MeshView mast = getMeshViewChild(MAST_INDEX);
|
||||
MeshView sail = getMeshViewChild(SAIL_INDEX);
|
||||
mast.getTransforms().setAll(
|
||||
new Rotate(degrees, -meshType.mastOffset, 0,0, new Point3D(0, 0, 1))
|
||||
new Rotate(degrees, 0, -meshType.mastOffset, 0, new Point3D(0, 0, 1))
|
||||
);
|
||||
sail.getTransforms().setAll(
|
||||
new Rotate(degrees, -meshType.sailOffset, 0,0, new Point3D(0, 0, 1))
|
||||
new Rotate(degrees, 0, -meshType.sailOffset,0, new Point3D(0, 0, 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideSail() {
|
||||
getMeshViewChild(SAIL_INDEX).setVisible(false);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class BoatObject extends Group {
|
||||
private Group wake;
|
||||
private Color colour = Color.BLACK;
|
||||
private Boolean isSelected = false;
|
||||
private Rotate rotation = new Rotate(0,0,1);
|
||||
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
||||
|
||||
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BoatObject extends Group {
|
||||
* Creates a BoatGroup with the default triangular boat polygon.
|
||||
*/
|
||||
public BoatObject() {
|
||||
boatAssets = ModelFactory.boatGameView(BoatMeshType.DINGHY, colour);
|
||||
boatAssets = ModelFactory.boatGameView(BoatMeshType.PIRATE_SHIP, colour);
|
||||
boatAssets.hideSail();
|
||||
boatAssets.getAssets().getTransforms().addAll(
|
||||
rotation
|
||||
@@ -66,8 +66,6 @@ public class BoatObject extends Group {
|
||||
* @param windDir .
|
||||
*/
|
||||
public void moveTo(double x, double y, double rotation, double velocity, Boolean sailIn, double windDir) {
|
||||
Double dx = Math.abs(boatAssets.getAssets().getLayoutX() - x);
|
||||
Double dy = Math.abs(boatAssets.getAssets().getLayoutY() - y);
|
||||
Platform.runLater(() -> {
|
||||
rotateTo(rotation, sailIn, windDir);
|
||||
this.layoutXProperty().setValue(x);
|
||||
|
||||
@@ -78,27 +78,35 @@ public class ModelFactory {
|
||||
public static BoatModel boatGameView(BoatMeshType boatType, Color primaryColour) {
|
||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||
boatAssets.getTransforms().setAll(
|
||||
new Rotate(-90, new Point3D(0,0,1)),
|
||||
new Scale(0.3, 0.3, 0.3)
|
||||
);
|
||||
return new BoatModel(boatAssets, null, boatType);
|
||||
}
|
||||
|
||||
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
|
||||
|
||||
Group boatAssets = new Group();
|
||||
MeshView hull = importFile(boatType.hullFile);
|
||||
MeshView hull = importSTL(boatType.hullFile);
|
||||
hull.setMaterial(new PhongMaterial(primaryColour));
|
||||
MeshView mast = importFile(boatType.mastFile);
|
||||
MeshView mast = importSTL(boatType.mastFile);
|
||||
mast.setMaterial(new PhongMaterial(primaryColour));
|
||||
MeshView sail = importFile(boatType.sailFile);
|
||||
MeshView sail = importSTL(boatType.sailFile);
|
||||
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
||||
|
||||
if (boatType.jibFile != null) {
|
||||
MeshView jib = importSTL(boatType.jibFile);
|
||||
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
||||
boatAssets.getChildren().addAll(hull, mast, sail, jib);
|
||||
} else {
|
||||
boatAssets.getChildren().addAll(hull, mast, sail);
|
||||
}
|
||||
|
||||
return boatAssets;
|
||||
}
|
||||
|
||||
private static MeshView importFile(String fileName) {
|
||||
private static MeshView importSTL(String fileName) {
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
importer.read(ModelFactory.class.getResource("/meshes/" + fileName));
|
||||
importer.read(ModelFactory.class.getResource("/meshes/boatSTLs/" + fileName));
|
||||
MeshView importedFile = new MeshView(importer.getImport());
|
||||
importedFile.setCache(true);
|
||||
importedFile.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
package seng302.visualiser;
|
||||
|
||||
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Application;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Camera;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.SceneAntialiasing;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* Created by cir27 on 7/09/17.
|
||||
*/
|
||||
public class test3d extends Application {
|
||||
|
||||
Group root = new Group();
|
||||
Scene scene;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
// camera = new PerspectiveCamera();
|
||||
// gameObjects = new Group();
|
||||
// root3D = new Group(camera, gameObjects);
|
||||
scene = new Scene(
|
||||
root, 1000, 1000, true, SceneAntialiasing.BALANCED
|
||||
);
|
||||
gameView3DTest();
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
// scene.setCamera(camera);
|
||||
// primaryStage.setScene(scene);
|
||||
// primaryStage.show();
|
||||
//
|
||||
// StlMeshImporter importer = new StlMeshImporter();
|
||||
// importer.read(test3d.class.getResource("/meshes/dinghy_hull.stl").toString());
|
||||
// MeshView boat = new MeshView(importer.getImport());
|
||||
// boat.setMaterial(new PhongMaterial(Color.GREENYELLOW));
|
||||
//
|
||||
// importer = new StlMeshImporter();
|
||||
// importer.read(getClass().getResource("/meshes/dinghy_mast.stl").toString());
|
||||
// MeshView mast = new MeshView(importer.getImport());
|
||||
// mast.setMaterial(new PhongMaterial(Color.GREENYELLOW));
|
||||
//
|
||||
// importer = new StlMeshImporter();
|
||||
// importer.read(getClass().getResource("/meshes/dinghy_sail.stl").toString());
|
||||
// MeshView sail = new MeshView(importer.getImport());
|
||||
// sail.setMaterial(new PhongMaterial(Color.LIGHTGREY));
|
||||
//
|
||||
// gameObjects.getChildren().addAll(boat, mast, sail);
|
||||
//
|
||||
// gameObjects.getTransforms().add(new Scale(25, 25,25));
|
||||
// gameObjects.getTransforms().add(new Translate(15, 20,0));
|
||||
// gameObjects.getTransforms().addAll(
|
||||
// new Rotate(90, new Point3D(0,0,1)),
|
||||
// new Rotate(90, new Point3D(0, 1, 0))
|
||||
// );
|
||||
//
|
||||
//// PointLight light = new PointLight();
|
||||
//// light.setLightOn(true);
|
||||
//// light.getTransforms().add(new Translate(15, 20, 0));
|
||||
////
|
||||
//// PointLight light2 = new PointLight();
|
||||
//// light2.setLightOn(true);
|
||||
//// light2.getTransforms().add(new Translate(30, 40, 0));
|
||||
//
|
||||
//// root3D.getChildren().addAll(light);
|
||||
//
|
||||
// scene.setOnKeyPressed(event -> {
|
||||
// switch (event.getCode()) {
|
||||
// case UP:
|
||||
// gameObjects.getTransforms().add(new Rotate(5, new Point3D(0,0,1)));
|
||||
// break;
|
||||
// case DOWN:
|
||||
// gameObjects.getTransforms().add(new Rotate(-5, new Point3D(0,0,1)));
|
||||
// break;
|
||||
// case LEFT:
|
||||
// gameObjects.getTransforms().add(new Rotate(-5, new Point3D(0,1,0)));
|
||||
// break;
|
||||
// case RIGHT:
|
||||
// gameObjects.getTransforms().add(new Rotate(5, new Point3D(0,1,0)));
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// AnimationTimer animationTimer = new AnimationTimer() {
|
||||
// @Override
|
||||
// public void handle(long now) {
|
||||
// sail.getTransforms().add(new Rotate(0.5, 0, -1.36653, 0, new Point3D(0, 0, 1)));
|
||||
// }
|
||||
// };
|
||||
//
|
||||
//// animationTimer.start();
|
||||
}
|
||||
|
||||
private void gameView3DTest() {
|
||||
GameView3D gameView3D = new GameView3D();
|
||||
root.getChildren().add(gameView3D.getAssets());
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 92 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308"
|
||||
maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0"
|
||||
prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8"
|
||||
prefWidth="1200.0" style="-fx-background-color: lightblue;" xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="seng302.visualiser.controllers.RaceViewController">
|
||||
<children>
|
||||
|
||||
@@ -24,7 +24,17 @@ public class ToggleSailSteps {
|
||||
@Given("^The game is running$")
|
||||
public void the_game_is_running() throws Throwable {
|
||||
mst = new MainServerThread();
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
client = new ClientToServerThread("localhost", 4942);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
GameState.setCurrentStage(GameStages.RACING);
|
||||
Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
|
||||
ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
|
||||
@@ -50,5 +60,6 @@ public class ToggleSailSteps {
|
||||
Assert.assertFalse(yacht.getSailIn());
|
||||
}
|
||||
mst.terminate();
|
||||
client.setSocketToClose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user