Merged master.
This commit is contained in:
@@ -313,14 +313,7 @@ public class MockRace extends Race {
|
||||
//Checks if the current boat has finished the race or not.
|
||||
boolean finish = this.isLastLeg(boat.getCurrentLeg());
|
||||
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds) {
|
||||
|
||||
checkPosition(boat, totalElapsedMilliseconds);
|
||||
|
||||
if (boat.getCurrentSpeed() == 0) {
|
||||
newOptimalVMG(boat);
|
||||
boat.setBearing(boat.calculateBearingToNextMarker());
|
||||
}
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds & boat.isSailsOut()) {
|
||||
|
||||
setBoatSpeed(boat);
|
||||
|
||||
@@ -339,9 +332,12 @@ public class MockRace extends Race {
|
||||
newOptimalVMG(boat);
|
||||
}
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
} else {
|
||||
boat.setCurrentSpeed(0);
|
||||
}
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
|
||||
}
|
||||
|
||||
private void newOptimalVMG(MockBoat boat) {
|
||||
|
||||
@@ -33,6 +33,8 @@ public class CommandFactory {
|
||||
case TACK_GYBE: return new TackGybeCommand(race, boat);
|
||||
case UPWIND: return new WindCommand(race, boat, true);
|
||||
case DOWNWIND: return new WindCommand(race, boat, false);
|
||||
case SAILS_OUT: return new SailsCommand(race, boat, true);
|
||||
case SAILS_IN: return new SailsCommand(race, boat, false);
|
||||
|
||||
default: throw new CommandConstructionException("Could not create command for BoatAction: " + action + ". Unknown BoatAction.");
|
||||
}
|
||||
|
||||
@@ -342,13 +342,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
double[] x = {
|
||||
pos.getX() - 9,
|
||||
pos.getX(),
|
||||
pos.getX() + 9 };
|
||||
pos.getX() + 9};
|
||||
|
||||
//The y coordinates of each vertex of the boat.
|
||||
double[] y = {
|
||||
pos.getY() + 15,
|
||||
pos.getY() - 15,
|
||||
pos.getY() + 15 };
|
||||
pos.getY() + 15};
|
||||
|
||||
//The above shape is essentially a triangle 24px wide, and 48 long.
|
||||
|
||||
@@ -359,6 +359,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
rotate(boat.getBearing().degrees(), pos.getX(), pos.getY());
|
||||
gc.fillPolygon(x, y, 3);
|
||||
gc.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws sails for a given boat on the canvas. Sail position is
|
||||
|
||||
@@ -4,9 +4,7 @@ package visualiser.model;
|
||||
* The properties of the boat currently being controlled by the player. Singleton.
|
||||
*/
|
||||
public class ThisBoat {
|
||||
// TODO Initialise sourceID to the sourceID given by the network
|
||||
private int sourceID = 125;
|
||||
private boolean sailsOut = true;
|
||||
private VisualiserBoat boat;
|
||||
private static ThisBoat instance = new ThisBoat();
|
||||
|
||||
private ThisBoat(){}
|
||||
@@ -16,18 +14,18 @@ public class ThisBoat {
|
||||
}
|
||||
|
||||
public void setSailsOut(boolean sailsOut) {
|
||||
this.sailsOut = sailsOut;
|
||||
}
|
||||
|
||||
public void setSourceID(int sourceID) {
|
||||
this.sourceID = sourceID;
|
||||
this.boat.setSailsOut(sailsOut);
|
||||
}
|
||||
|
||||
public boolean isSailsOut() {
|
||||
return sailsOut;
|
||||
return this.boat.isSailsOut();
|
||||
}
|
||||
|
||||
public int getSourceID() {
|
||||
return sourceID;
|
||||
return this.boat.getSourceID();
|
||||
}
|
||||
|
||||
public void setBoat(VisualiserBoat boat) {
|
||||
this.boat = boat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,7 @@ public class VisualiserRaceState extends RaceState {
|
||||
|
||||
if (boat.getSourceID() == getPlayerBoatID()) {
|
||||
boat.setClientBoat(true);
|
||||
ThisBoat.getInstance().setBoat(boat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user