Works for clients and server.

Due to the information being sent and received, it only currently works on client side boats.

#story[1111]
This commit is contained in:
Kusal Ekanayake
2017-08-03 19:07:30 +12:00
parent 99d5545ed3
commit f8af9cc259
2 changed files with 23 additions and 22 deletions
+1 -4
View File
@@ -282,9 +282,6 @@ public class Yacht {
this.velocityProperty.set(velocity); this.velocityProperty.set(velocity);
} }
public void updateSailsInProperty(Boolean clientSails) {
this.clientSailsIn = clientSails;
}
public void setMarkRoundingTime(Long markRoundingTime) { public void setMarkRoundingTime(Long markRoundingTime) {
this.markRoundTime = markRoundingTime; this.markRoundTime = markRoundingTime;
@@ -407,7 +404,7 @@ public class Yacht {
this.velocity = velocity; this.velocity = velocity;
updateVelocityProperty(velocity); updateVelocityProperty(velocity);
for (YachtLocationListener yll : locationListeners) { for (YachtLocationListener yll : locationListeners) {
yll.notifyLocation(this, lat, lon, heading, velocity, this.clientSailsIn); yll.notifyLocation(this, lat, lon, heading, velocity, clientSailsIn);
} }
} }
@@ -90,21 +90,14 @@ public class BoatObject extends Group {
// annotationBox = new AnnotationBox(); // annotationBox = new AnnotationBox();
// annotationBox.setFill(colour); // annotationBox.setFill(colour);
sail = new Polygon(0.0, BOAT_HEIGHT / 4,
0.0, BOAT_HEIGHT);
sailState = 0;
sail.setStrokeWidth(2.0);
sail.setStroke(Color.SILVER);
sail.setFill(Color.TRANSPARENT);
sail.setCache(true);
animateSail();
leftLayLine = new Line(); leftLayLine = new Line();
rightLayline = new Line(); rightLayline = new Line();
trail.getStrokeDashArray().setAll(5d, 10d); trail.getStrokeDashArray().setAll(5d, 10d);
trail.setCache(true); trail.setCache(true);
wake = new Wake(0, -BOAT_HEIGHT); wake = new Wake(0, -BOAT_HEIGHT);
wake.setVisible(true); wake.setVisible(true);
super.getChildren().addAll(boatPoly, sail);//, annotationBox); super.getChildren().addAll(boatPoly);
} }
public void setFill (Paint value) { public void setFill (Paint value) {
@@ -128,15 +121,16 @@ public class BoatObject extends Group {
rotateTo(rotation, sailIn); rotateTo(rotation, sailIn);
boatPoly.setLayoutX(x); boatPoly.setLayoutX(x);
boatPoly.setLayoutY(y); boatPoly.setLayoutY(y);
if (isPlayer && !sailIn) {
animateSail();
sail.setLayoutX(x); sail.setLayoutX(x);
sail.setLayoutY(y); sail.setLayoutY(y);
if (!sailIn) { } else if (isPlayer){
animateSail();
} else {
sail.getPoints().clear(); sail.getPoints().clear();
sail.getPoints().addAll(0.0,BOAT_HEIGHT / 4, sail.getPoints().addAll(0.0,BOAT_HEIGHT / 4,
0.0, BOAT_HEIGHT); 0.0, BOAT_HEIGHT);
sail.setLayoutX(x);
sail.setLayoutY(y);
} }
wake.setLayoutX(x); wake.setLayoutX(x);
wake.setLayoutY(y); wake.setLayoutY(y);
@@ -164,10 +158,10 @@ public class BoatObject extends Group {
private void rotateTo(double rotation, boolean sailsIn) { private void rotateTo(double rotation, boolean sailsIn) {
boatPoly.getTransforms().setAll(new Rotate(rotation)); boatPoly.getTransforms().setAll(new Rotate(rotation));
if (sailsIn) { if (isPlayer && sailsIn) {
sail.getTransforms().setAll(new Rotate(GameState.getWindDirection() + 95.0)); sail.getTransforms().setAll(new Rotate(95.0));
} else { } else if (isPlayer){
sail.getTransforms().setAll(new Rotate(GameState.getWindDirection())); sail.getTransforms().setAll(new Rotate(90.0));
} }
} }
private void animateSail(){ private void animateSail(){
@@ -311,6 +305,16 @@ public class BoatObject extends Group {
boatPoly.setStroke(Color.BLACK); boatPoly.setStroke(Color.BLACK);
boatPoly.setStrokeWidth(3); boatPoly.setStrokeWidth(3);
isPlayer = true; isPlayer = true;
sail = new Polygon(0.0, BOAT_HEIGHT / 4,
0.0, BOAT_HEIGHT);
sailState = 0;
sail.setStrokeWidth(2.0);
sail.setStroke(Color.BLACK);
sail.setFill(Color.TRANSPARENT);
sail.setCache(true);
super.getChildren().clear();
super.getChildren().addAll(boatPoly, sail);
animateSail();
} }
public void setTrajectory(double heading, double velocity) { public void setTrajectory(double heading, double velocity) {