mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge on to develop
story[955]
This commit is contained in:
@@ -62,8 +62,8 @@ public class BoatGroup extends RaceObject {
|
|||||||
/**
|
/**
|
||||||
* Creates a BoatGroup with the default triangular boat polygon.
|
* Creates a BoatGroup with the default triangular boat polygon.
|
||||||
*
|
*
|
||||||
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
||||||
* to tell which BoatGroup to update.
|
* to tell which BoatGroup to update.
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
*/
|
*/
|
||||||
public BoatGroup(Yacht boat, Color color) {
|
public BoatGroup(Yacht boat, Color color) {
|
||||||
@@ -75,11 +75,11 @@ public class BoatGroup extends RaceObject {
|
|||||||
* Creates a BoatGroup with the boat being the default polygon. The head of the boat should be
|
* Creates a BoatGroup with the boat being the default polygon. The head of the boat should be
|
||||||
* at point (0,0).
|
* at point (0,0).
|
||||||
*
|
*
|
||||||
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
* @param boat The boat that the BoatGroup will represent. Must contain an ID which will be used
|
||||||
* to tell which BoatGroup to update.
|
* to tell which BoatGroup to update.
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
||||||
* polygon.
|
* polygon.
|
||||||
*/
|
*/
|
||||||
public BoatGroup(Yacht boat, Color color, double... points) {
|
public BoatGroup(Yacht boat, Color color, double... points) {
|
||||||
this.boat = boat;
|
this.boat = boat;
|
||||||
@@ -89,9 +89,9 @@ public class BoatGroup extends RaceObject {
|
|||||||
/**
|
/**
|
||||||
* Creates the javafx objects that will be the in the group by default.
|
* Creates the javafx objects that will be the in the group by default.
|
||||||
*
|
*
|
||||||
* @param color The colour of the boat polygon and the trailing line.
|
* @param color The colour of the boat polygon and the trailing line.
|
||||||
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
* @param points An array of co-ordinates x1,y1,x2,y2,x3,y3... that will make up the boat
|
||||||
* polygon.
|
* polygon.
|
||||||
*/
|
*/
|
||||||
private void initChildren(Color color, double... points) {
|
private void initChildren(Color color, double... points) {
|
||||||
boatPoly = new Polygon(points);
|
boatPoly = new Polygon(points);
|
||||||
@@ -104,11 +104,11 @@ public class BoatGroup extends RaceObject {
|
|||||||
velocityObject = new Text(String.valueOf(boat.getVelocity()));
|
velocityObject = new Text(String.valueOf(boat.getVelocity()));
|
||||||
DateFormat format = new SimpleDateFormat("mm:ss");
|
DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
String timeToNextMark = format
|
String timeToNextMark = format
|
||||||
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
||||||
estTimeToNextMarkObject = new Text("Next mark: " + timeToNextMark);
|
estTimeToNextMarkObject = new Text("Next mark: " + timeToNextMark);
|
||||||
if (boat.getMarkRoundingTime() != null) {
|
if (boat.getMarkRoundingTime() != null) {
|
||||||
String elapsedTime = format
|
String elapsedTime = format
|
||||||
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
||||||
legTimeObject = new Text("Last mark: " + elapsedTime);
|
legTimeObject = new Text("Last mark: " + elapsedTime);
|
||||||
} else {
|
} else {
|
||||||
legTimeObject = new Text("Last mark: -");
|
legTimeObject = new Text("Last mark: -");
|
||||||
@@ -126,7 +126,7 @@ public class BoatGroup extends RaceObject {
|
|||||||
estTimeToNextMarkObject.setX(ESTTIMETONEXTMARK_X_OFFSET);
|
estTimeToNextMarkObject.setX(ESTTIMETONEXTMARK_X_OFFSET);
|
||||||
estTimeToNextMarkObject.setY(ESTTIMETONEXTMARK_Y_OFFSET);
|
estTimeToNextMarkObject.setY(ESTTIMETONEXTMARK_Y_OFFSET);
|
||||||
estTimeToNextMarkObject
|
estTimeToNextMarkObject
|
||||||
.relocate(estTimeToNextMarkObject.getX(), estTimeToNextMarkObject.getY());
|
.relocate(estTimeToNextMarkObject.getX(), estTimeToNextMarkObject.getY());
|
||||||
|
|
||||||
legTimeObject.setX(LEGTIME_X_OFFSET);
|
legTimeObject.setX(LEGTIME_X_OFFSET);
|
||||||
legTimeObject.setY(LEGTIME_Y_OFFSET);
|
legTimeObject.setY(LEGTIME_Y_OFFSET);
|
||||||
@@ -134,8 +134,8 @@ public class BoatGroup extends RaceObject {
|
|||||||
|
|
||||||
wake = new Wake(0, -BOAT_HEIGHT);
|
wake = new Wake(0, -BOAT_HEIGHT);
|
||||||
super.getChildren()
|
super.getChildren()
|
||||||
.addAll(teamNameObject, velocityObject, boatPoly, estTimeToNextMarkObject,
|
.addAll(teamNameObject, velocityObject, boatPoly, estTimeToNextMarkObject,
|
||||||
legTimeObject);
|
legTimeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,9 +145,9 @@ public class BoatGroup extends RaceObject {
|
|||||||
*/
|
*/
|
||||||
private void initChildren(Color color) {
|
private void initChildren(Color color) {
|
||||||
initChildren(color,
|
initChildren(color,
|
||||||
-BOAT_WIDTH / 2, BOAT_HEIGHT / 2,
|
-BOAT_WIDTH / 2, BOAT_HEIGHT / 2,
|
||||||
0.0, -BOAT_HEIGHT / 2,
|
0.0, -BOAT_HEIGHT / 2,
|
||||||
BOAT_WIDTH / 2, BOAT_HEIGHT / 2);
|
BOAT_WIDTH / 2, BOAT_HEIGHT / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,8 +176,8 @@ public class BoatGroup extends RaceObject {
|
|||||||
/**
|
/**
|
||||||
* Moves the boat and its children annotations to coordinates specified
|
* Moves the boat and its children annotations to coordinates specified
|
||||||
*
|
*
|
||||||
* @param x The X coordinate to move the boat to
|
* @param x The X coordinate to move the boat to
|
||||||
* @param y The Y coordinate to move the boat to
|
* @param y The Y coordinate to move the boat to
|
||||||
* @param rotation The heading in degrees from north the boat should rotate to.
|
* @param rotation The heading in degrees from north the boat should rotate to.
|
||||||
*/
|
*/
|
||||||
public void moveTo(double x, double y, double rotation) {
|
public void moveTo(double x, double y, double rotation) {
|
||||||
@@ -211,7 +211,7 @@ public class BoatGroup extends RaceObject {
|
|||||||
* Updates the position of all graphics in the BoatGroup based off of the given time interval.
|
* Updates the position of all graphics in the BoatGroup based off of the given time interval.
|
||||||
*
|
*
|
||||||
* @param timeInterval The interval, in milliseconds, the boat should update it's position based
|
* @param timeInterval The interval, in milliseconds, the boat should update it's position based
|
||||||
* on.
|
* on.
|
||||||
*/
|
*/
|
||||||
public void updatePosition(long timeInterval) {
|
public void updatePosition(long timeInterval) {
|
||||||
//Calculate the movement of the boat.
|
//Calculate the movement of the boat.
|
||||||
@@ -226,10 +226,10 @@ public class BoatGroup extends RaceObject {
|
|||||||
distanceTravelled = 0;
|
distanceTravelled = 0;
|
||||||
if (lastPoint != null) {
|
if (lastPoint != null) {
|
||||||
Line l = new Line(
|
Line l = new Line(
|
||||||
lastPoint.getX(),
|
lastPoint.getX(),
|
||||||
lastPoint.getY(),
|
lastPoint.getY(),
|
||||||
boatPoly.getLayoutX(),
|
boatPoly.getLayoutX(),
|
||||||
boatPoly.getLayoutY()
|
boatPoly.getLayoutY()
|
||||||
);
|
);
|
||||||
l.getStrokeDashArray().setAll(3d, 7d);
|
l.getStrokeDashArray().setAll(3d, 7d);
|
||||||
l.setStroke(boat.getColour());
|
l.setStroke(boat.getColour());
|
||||||
@@ -248,11 +248,11 @@ public class BoatGroup extends RaceObject {
|
|||||||
*
|
*
|
||||||
* @param newXValue The X co-ordinate the boat needs to move to.
|
* @param newXValue The X co-ordinate the boat needs to move to.
|
||||||
* @param newYValue The Y co-ordinate the boat needs to move to.
|
* @param newYValue The Y co-ordinate the boat needs to move to.
|
||||||
* @param rotation Rotation to move graphics to.
|
* @param rotation Rotation to move graphics to.
|
||||||
* @param raceIds RaceID of the object to move.
|
* @param raceIds RaceID of the object to move.
|
||||||
*/
|
*/
|
||||||
public void setDestination(double newXValue, double newYValue, double rotation,
|
public void setDestination(double newXValue, double newYValue, double rotation,
|
||||||
double groundSpeed, int... raceIds) {
|
double groundSpeed, int... raceIds) {
|
||||||
if (hasRaceId(raceIds)) {
|
if (hasRaceId(raceIds)) {
|
||||||
if (setToInitialLocation) {
|
if (setToInitialLocation) {
|
||||||
destinationSet = true;
|
destinationSet = true;
|
||||||
@@ -281,18 +281,18 @@ public class BoatGroup extends RaceObject {
|
|||||||
wakeGenerationDelay--;
|
wakeGenerationDelay--;
|
||||||
} else {
|
} else {
|
||||||
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal,
|
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal,
|
||||||
boat.getVelocity());
|
boat.getVelocity());
|
||||||
}
|
}
|
||||||
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
|
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
|
||||||
DateFormat format = new SimpleDateFormat("mm:ss");
|
DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
// estimate time to next mark
|
// estimate time to next mark
|
||||||
String timeToNextMark = format
|
String timeToNextMark = format
|
||||||
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
|
||||||
estTimeToNextMarkObject.setText("Next mark: " + timeToNextMark);
|
estTimeToNextMarkObject.setText("Next mark: " + timeToNextMark);
|
||||||
// elapsed time
|
// elapsed time
|
||||||
if (boat.getMarkRoundingTime() != null) {
|
if (boat.getMarkRoundingTime() != null) {
|
||||||
String elapsedTime = format
|
String elapsedTime = format
|
||||||
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
|
||||||
legTimeObject.setText("Last mark: " + elapsedTime);
|
legTimeObject.setText("Last mark: " + elapsedTime);
|
||||||
} else {
|
} else {
|
||||||
legTimeObject.setText("Last mark: -");
|
legTimeObject.setText("Last mark: -");
|
||||||
@@ -311,10 +311,10 @@ public class BoatGroup extends RaceObject {
|
|||||||
setCallCount = 5;
|
setCallCount = 5;
|
||||||
if (lastPoint != null) {
|
if (lastPoint != null) {
|
||||||
Line l = new Line(
|
Line l = new Line(
|
||||||
lastPoint.getX(),
|
lastPoint.getX(),
|
||||||
lastPoint.getY(),
|
lastPoint.getY(),
|
||||||
newXValue,
|
newXValue,
|
||||||
newYValue
|
newYValue
|
||||||
);
|
);
|
||||||
l.getStrokeDashArray().setAll(3d, 7d);
|
l.getStrokeDashArray().setAll(3d, 7d);
|
||||||
l.setStroke(boatPoly.getFill());
|
l.setStroke(boatPoly.getFill());
|
||||||
@@ -328,16 +328,16 @@ public class BoatGroup extends RaceObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDestination(double newXValue, double newYValue, double groundSpeed,
|
public void setDestination(double newXValue, double newYValue, double groundSpeed,
|
||||||
int... raceIDs) {
|
int... raceIDs) {
|
||||||
destinationSet = true;
|
destinationSet = true;
|
||||||
|
|
||||||
if (hasRaceId(raceIDs)) {
|
if (hasRaceId(raceIDs)) {
|
||||||
double rotation = Math.abs(
|
double rotation = Math.abs(
|
||||||
Math.toDegrees(
|
Math.toDegrees(
|
||||||
Math.atan(
|
Math.atan(
|
||||||
(newYValue - boatPoly.getLayoutY()) / (newXValue - boatPoly.getLayoutX())
|
(newYValue - boatPoly.getLayoutY()) / (newXValue - boatPoly.getLayoutX())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
setDestination(newXValue, newYValue, rotation, groundSpeed, raceIDs);
|
setDestination(newXValue, newYValue, rotation, groundSpeed, raceIDs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user