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.
|
//Checks if the current boat has finished the race or not.
|
||||||
boolean finish = this.isLastLeg(boat.getCurrentLeg());
|
boolean finish = this.isLastLeg(boat.getCurrentLeg());
|
||||||
|
|
||||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds) {
|
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds & boat.isSailsOut()) {
|
||||||
|
|
||||||
checkPosition(boat, totalElapsedMilliseconds);
|
|
||||||
|
|
||||||
if (boat.getCurrentSpeed() == 0) {
|
|
||||||
newOptimalVMG(boat);
|
|
||||||
boat.setBearing(boat.calculateBearingToNextMarker());
|
|
||||||
}
|
|
||||||
|
|
||||||
setBoatSpeed(boat);
|
setBoatSpeed(boat);
|
||||||
|
|
||||||
@@ -339,9 +332,12 @@ public class MockRace extends Race {
|
|||||||
newOptimalVMG(boat);
|
newOptimalVMG(boat);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateEstimatedTime(boat);
|
} else {
|
||||||
|
boat.setCurrentSpeed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.updateEstimatedTime(boat);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newOptimalVMG(MockBoat boat) {
|
private void newOptimalVMG(MockBoat boat) {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class CommandFactory {
|
|||||||
case TACK_GYBE: return new TackGybeCommand(race, boat);
|
case TACK_GYBE: return new TackGybeCommand(race, boat);
|
||||||
case UPWIND: return new WindCommand(race, boat, true);
|
case UPWIND: return new WindCommand(race, boat, true);
|
||||||
case DOWNWIND: return new WindCommand(race, boat, false);
|
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.");
|
default: throw new CommandConstructionException("Could not create command for BoatAction: " + action + ". Unknown BoatAction.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
rotate(boat.getBearing().degrees(), pos.getX(), pos.getY());
|
rotate(boat.getBearing().degrees(), pos.getX(), pos.getY());
|
||||||
gc.fillPolygon(x, y, 3);
|
gc.fillPolygon(x, y, 3);
|
||||||
gc.restore();
|
gc.restore();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws sails for a given boat on the canvas. Sail position is
|
* 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.
|
* The properties of the boat currently being controlled by the player. Singleton.
|
||||||
*/
|
*/
|
||||||
public class ThisBoat {
|
public class ThisBoat {
|
||||||
// TODO Initialise sourceID to the sourceID given by the network
|
private VisualiserBoat boat;
|
||||||
private int sourceID = 125;
|
|
||||||
private boolean sailsOut = true;
|
|
||||||
private static ThisBoat instance = new ThisBoat();
|
private static ThisBoat instance = new ThisBoat();
|
||||||
|
|
||||||
private ThisBoat(){}
|
private ThisBoat(){}
|
||||||
@@ -16,18 +14,18 @@ public class ThisBoat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSailsOut(boolean sailsOut) {
|
public void setSailsOut(boolean sailsOut) {
|
||||||
this.sailsOut = sailsOut;
|
this.boat.setSailsOut(sailsOut);
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourceID(int sourceID) {
|
|
||||||
this.sourceID = sourceID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSailsOut() {
|
public boolean isSailsOut() {
|
||||||
return sailsOut;
|
return this.boat.isSailsOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSourceID() {
|
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()) {
|
if (boat.getSourceID() == getPlayerBoatID()) {
|
||||||
boat.setClientBoat(true);
|
boat.setClientBoat(true);
|
||||||
|
ThisBoat.getInstance().setBoat(boat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user