From 8fc00fd750500aa2c15ce2788ca8f0594cadc4ad Mon Sep 17 00:00:00 2001 From: Calum Date: Wed, 26 Jul 2017 16:01:01 +1200 Subject: [PATCH] Enabled boat path for only the player. #story[987] --- .../seng302/fxObjects/BoatAnnotations.java | 2 +- .../java/seng302/fxObjects/BoatGroup.java | 45 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/java/seng302/fxObjects/BoatAnnotations.java b/src/main/java/seng302/fxObjects/BoatAnnotations.java index 289007d2..331ede86 100644 --- a/src/main/java/seng302/fxObjects/BoatAnnotations.java +++ b/src/main/java/seng302/fxObjects/BoatAnnotations.java @@ -111,7 +111,7 @@ public class BoatAnnotations extends Group{ } } - private void setVisible(boolean nameVisibility, boolean speedVisibility, + void setVisible(boolean nameVisibility, boolean speedVisibility, boolean estTimeVisibility, boolean lastMarkVisibility) { int totalVisible = 0; diff --git a/src/main/java/seng302/fxObjects/BoatGroup.java b/src/main/java/seng302/fxObjects/BoatGroup.java index 6279ba97..e4874695 100644 --- a/src/main/java/seng302/fxObjects/BoatGroup.java +++ b/src/main/java/seng302/fxObjects/BoatGroup.java @@ -51,6 +51,7 @@ public class BoatGroup extends Group { private BoatAnnotations boatAnnotations; private Color color; private Boolean isSelected = true; //All boats are initialised as selected\ + private boolean isPlayer = false; /** * Creates a BoatGroup with the default triangular boat polygon. @@ -173,28 +174,27 @@ public class BoatGroup extends Group { if (framesToMove <= 0) { isStopped = true; } + if (distanceTravelled > 70 && isPlayer) { + distanceTravelled = 0d; -// if (distanceTravelled > 70) { -// distanceTravelled = 0d; -// -// if (lastPoint != null) { -// Line l = new Line( -// lastPoint.getX(), -// lastPoint.getY(), -// boatPoly.getLayoutX(), -// boatPoly.getLayoutY() -// ); -// l.getStrokeDashArray().setAll(3d, 7d); -// l.setStroke(boat.getColour()); -// l.setCache(true); -// l.setCacheHint(CacheHint.SPEED); -// lineGroup.getChildren().add(l); -// } -// -// if (destinationSet) { -// lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY()); -// } -// } + if (lastPoint != null) { + Line l = new Line( + lastPoint.getX(), + lastPoint.getY(), + boatPoly.getLayoutX(), + boatPoly.getLayoutY() + ); + l.getStrokeDashArray().setAll(3d, 7d); + l.setStroke(boat.getColour()); + l.setCache(true); + l.setCacheHint(CacheHint.SPEED); + lineGroup.getChildren().add(l); + } + + if (destinationSet) { + lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY()); + } + } // wake.updatePosition(); } @@ -279,7 +279,7 @@ public class BoatGroup extends Group { } public void setVisibility (boolean teamName, boolean velocity, boolean estTime, boolean legTime, boolean trail, boolean wake) { - boatAnnotations.setVisibile(teamName, velocity, estTime, legTime); + boatAnnotations.setVisible(teamName, velocity, estTime, legTime); this.wake.setVisible(wake); this.lineGroup.setVisible(trail); } @@ -361,5 +361,6 @@ public class BoatGroup extends Group { boatPoly.setStroke(Color.BLACK); boatPoly.setStrokeWidth(3); boatAnnotations.setAsPlayer(); + isPlayer = true; } } \ No newline at end of file