Merged dev back on

#story[1293]
This commit is contained in:
William Muir
2017-09-25 11:26:44 +13:00
parent 8a0ad8d6a9
commit 29b97a194d
2 changed files with 40 additions and 38 deletions
@@ -433,7 +433,7 @@ public class GameState implements Runnable {
* @param yacht The yacht to disable * @param yacht The yacht to disable
*/ */
private void boatTempShutDown(ServerYacht yacht) { private void boatTempShutDown(ServerYacht yacht) {
yacht.setSpeedMultiplier(0); yacht.setPowerUpSpeedMultiplier(0);
Timer shutDownTimer = new Timer("Shutdown Timer"); Timer shutDownTimer = new Timer("Shutdown Timer");
shutDownTimer.schedule(new TimerTask() { shutDownTimer.schedule(new TimerTask() {
@Override @Override
@@ -542,13 +542,13 @@ public class GameState implements Runnable {
TokenType tokenType = collidedToken.getTokenType(); TokenType tokenType = collidedToken.getTokenType();
switch (tokenType) { switch (tokenType) {
case BOOST: case BOOST:
yacht.setSpeedMultiplier(VELOCITY_BOOST_MULTIPLIER); yacht.setPowerUpSpeedMultiplier(VELOCITY_BOOST_MULTIPLIER);
break; break;
case BUMPER: case BUMPER:
// TODO: 22/09/17 wmu16 // TODO: 22/09/17 wmu16
break; break;
case HANDLING: case HANDLING:
yacht.setHandlingMultiplier(HANDLING_BOOST_MULTIPLIER); yacht.setPowerUpHandlingMultiplier(HANDLING_BOOST_MULTIPLIER);
break; break;
case WIND_WALKER: case WIND_WALKER:
// TODO: 22/09/17 wmu16 // TODO: 22/09/17 wmu16
@@ -634,23 +634,29 @@ public class GameState implements Runnable {
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading()); Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle); Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
Double maxBoatSpeed = Double maxBoatSpeed =
GeoUtility.knotsToMMS(boatSpeedInKnots) * serverSpeedMultiplier * yacht.getSpeedMultiplier() * yacht.getMaxSpeedMultiplier(); GeoUtility.knotsToMMS(boatSpeedInKnots) * serverSpeedMultiplier * yacht
.getPowerUpSpeedMultiplier() * yacht.getBoatTypeSpeedMultiplier();
Double currentVelocity = yacht.getCurrentVelocity(); Double currentVelocity = yacht.getCurrentVelocity();
// TODO: 15/08/17 remove magic numbers from these equations. // TODO: 15/08/17 remove magic numbers from these equations.
if (yacht.getSailIn()) { if (yacht.getSailIn()) {
if (currentVelocity < maxBoatSpeed - 500) { if (currentVelocity < maxBoatSpeed - 500) {
yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAccelerationMultiplier()); yacht.changeVelocity(
(maxBoatSpeed / 100) * yacht.getBoatTypeAccelerationMultiplier());
} else if (currentVelocity > maxBoatSpeed + 500) { } else if (currentVelocity > maxBoatSpeed + 500) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier()); yacht.changeVelocity(
(-currentVelocity / 200) * yacht.getBoatTypeAccelerationMultiplier());
} else { } else {
yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAccelerationMultiplier()); yacht
.setCurrentVelocity((maxBoatSpeed) * yacht.getBoatTypeAccelerationMultiplier());
} }
} else { } else {
if (currentVelocity > 3000) { if (currentVelocity > 3000) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier()); yacht.changeVelocity(
(-currentVelocity / 200) * yacht.getBoatTypeAccelerationMultiplier());
} else if (currentVelocity > 100) { } else if (currentVelocity > 100) {
yacht.changeVelocity((-currentVelocity / 50) * yacht.getAccelerationMultiplier()); yacht.changeVelocity(
(-currentVelocity / 50) * yacht.getBoatTypeAccelerationMultiplier());
} else if (currentVelocity <= 100) { } else if (currentVelocity <= 100) {
yacht.setCurrentVelocity(0d); yacht.setCurrentVelocity(0d);
} }
+25 -29
View File
@@ -11,10 +11,6 @@ import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
import java.util.Observable;
import java.util.Observer;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
/** /**
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses) * Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
@@ -28,9 +24,9 @@ public class ServerYacht {
//Boat info //Boat info
private BoatMeshType boatType; private BoatMeshType boatType;
private Double turnStep = 5.0; private Double turnStep = 5.0;
private Double maxSpeedMultiplier = 1.0; private Double boatTypeSpeedMultiplier = 1.0;
private Double turnStepMultiplier = 1.0; private Double boatTypeTurnStepMultiplier = 1.0;
private Double accelerationMultiplier = 1.0; private Double boatTypeAccelerationMultiplier = 1.0;
private Integer sourceId; private Integer sourceId;
private String hullID; //matches HullNum in the XML spec. private String hullID; //matches HullNum in the XML spec.
private String shortName; private String shortName;
@@ -60,8 +56,8 @@ public class ServerYacht {
//PowerUp //PowerUp
private TokenType powerUp; private TokenType powerUp;
private Long powerUpStartTime; private Long powerUpStartTime;
private Integer speedMultiplier; private Integer powerUpSpeedMultiplier;
private Integer handlingMultiplier; private Integer powerUpHandlingMultiplier;
public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName, public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
@@ -83,8 +79,8 @@ public class ServerYacht {
this.legNumber = 0; this.legNumber = 0;
this.boatColor = Colors.getColor(sourceId - 1); this.boatColor = Colors.getColor(sourceId - 1);
this.powerUp = null; this.powerUp = null;
this.speedMultiplier = 1; this.powerUpSpeedMultiplier = 1;
this.handlingMultiplier = 1; this.powerUpHandlingMultiplier = 1;
this.hasEnteredRoundingZone = false; this.hasEnteredRoundingZone = false;
this.hasPassedLine = false; this.hasPassedLine = false;
@@ -122,8 +118,8 @@ public class ServerYacht {
public void powerDown() { public void powerDown() {
this.powerUp = null; this.powerUp = null;
this.speedMultiplier = 1; this.powerUpSpeedMultiplier = 1;
this.handlingMultiplier = 1; this.powerUpHandlingMultiplier = 1;
} }
public Long getPowerUpStartTime() { public Long getPowerUpStartTime() {
@@ -140,7 +136,7 @@ public class ServerYacht {
* @param amount the amount by which to adjust the boat heading. * @param amount the amount by which to adjust the boat heading.
*/ */
public void adjustHeading(Double amount) { public void adjustHeading(Double amount) {
Double newVal = heading + amount * handlingMultiplier * turnStepMultiplier; Double newVal = heading + amount * powerUpHandlingMultiplier * boatTypeTurnStepMultiplier;
lastHeading = heading; lastHeading = heading;
heading = (double) Math.floorMod(newVal.longValue(), 360L); heading = (double) Math.floorMod(newVal.longValue(), 360L);
} }
@@ -433,18 +429,18 @@ public class ServerYacht {
} }
public void setBoatType(BoatMeshType boatType) { public void setBoatType(BoatMeshType boatType) {
this.accelerationMultiplier = boatType.accelerationMultiplier; this.boatTypeAccelerationMultiplier = boatType.accelerationMultiplier;
this.maxSpeedMultiplier = boatType.maxSpeedMultiplier; this.boatTypeSpeedMultiplier = boatType.maxSpeedMultiplier;
this.turnStepMultiplier = boatType.turnStep; this.boatTypeTurnStepMultiplier = boatType.turnStep;
this.boatType = boatType; this.boatType = boatType;
} }
public Double getMaxSpeedMultiplier() { public Double getBoatTypeSpeedMultiplier() {
return maxSpeedMultiplier; return boatTypeSpeedMultiplier;
} }
public Double getAccelerationMultiplier(){ public Double getBoatTypeAccelerationMultiplier() {
return accelerationMultiplier; return boatTypeAccelerationMultiplier;
} }
@@ -452,19 +448,19 @@ public class ServerYacht {
return boatType; return boatType;
} }
public Integer getSpeedMultiplier() { public Integer getPowerUpSpeedMultiplier() {
return speedMultiplier; return powerUpSpeedMultiplier;
} }
public void setSpeedMultiplier(Integer speedMultiplier) { public void setPowerUpSpeedMultiplier(Integer powerUpSpeedMultiplier) {
this.speedMultiplier = speedMultiplier; this.powerUpSpeedMultiplier = powerUpSpeedMultiplier;
} }
public Integer getHandlingMultiplier() { public Integer getPowerUpHandlingMultiplier() {
return handlingMultiplier; return powerUpHandlingMultiplier;
} }
public void setHandlingMultiplier(Integer handlingMultiplier) { public void setPowerUpHandlingMultiplier(Integer powerUpHandlingMultiplier) {
this.handlingMultiplier = handlingMultiplier; this.powerUpHandlingMultiplier = powerUpHandlingMultiplier;
} }
} }