Fixed merge errors and reimplemented handling multiplier

#story[1274]
This commit is contained in:
Kusal Ekanayake
2017-09-23 15:04:11 +12:00
parent 9112183ac3
commit 364264377a
5 changed files with 22 additions and 17 deletions
@@ -462,17 +462,17 @@ public class GameState implements Runnable {
// 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.getAcceleration()); yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAccelerationMultiplier());
} else if (currentVelocity > maxBoatSpeed + 500) { } else if (currentVelocity > maxBoatSpeed + 500) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration()); yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
} else { } else {
yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAcceleration()); yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAccelerationMultiplier());
} }
} else { } else {
if (currentVelocity > 3000) { if (currentVelocity > 3000) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration()); yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
} else if (currentVelocity > 100) { } else if (currentVelocity > 100) {
yacht.changeVelocity((-currentVelocity / 50) * yacht.getAcceleration()); yacht.changeVelocity((-currentVelocity / 50) * yacht.getAccelerationMultiplier());
} else if (currentVelocity <= 100) { } else if (currentVelocity <= 100) {
yacht.setCurrentVelocity(0d); yacht.setCurrentVelocity(0d);
} }
+9 -5
View File
@@ -29,7 +29,8 @@ public class ServerYacht {
private BoatMeshType boatType; private BoatMeshType boatType;
private Double turnStep = 5.0; private Double turnStep = 5.0;
private Double maxSpeedMultiplier = 1.0; private Double maxSpeedMultiplier = 1.0;
private Double acceleration = 1.0; private Double turnStepMultiplier = 1.0;
private Double accelerationMultiplier = 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;
@@ -133,7 +134,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; Double newVal = heading + (amount * turnStepMultiplier);
lastHeading = heading; lastHeading = heading;
heading = (double) Math.floorMod(newVal.longValue(), 360L); heading = (double) Math.floorMod(newVal.longValue(), 360L);
} }
@@ -272,7 +273,7 @@ public class ServerYacht {
private void turnTowardsHeading(Double newHeading) { private void turnTowardsHeading(Double newHeading) {
Double newVal = heading - newHeading; Double newVal = heading - newHeading;
if (Math.floorMod(newVal.longValue(), 360L) > 180) { if (Math.floorMod(newVal.longValue(), 360L) > 180) {
adjustHeading(turnStep / 5); adjustHeading(turnStep / 5);
} else { } else {
adjustHeading(-turnStep / 5); adjustHeading(-turnStep / 5);
} }
@@ -426,6 +427,9 @@ public class ServerYacht {
} }
public void setBoatType(BoatMeshType boatType) { public void setBoatType(BoatMeshType boatType) {
this.accelerationMultiplier = boatType.accelerationMultiplier;
this.maxSpeedMultiplier = boatType.maxSpeedMultiplier;
this.turnStepMultiplier = boatType.turnStep;
this.boatType = boatType; this.boatType = boatType;
} }
@@ -433,8 +437,8 @@ public class ServerYacht {
return maxSpeedMultiplier; return maxSpeedMultiplier;
} }
public Double getAcceleration(){ public Double getAccelerationMultiplier(){
return acceleration; return accelerationMultiplier;
} }
@@ -131,7 +131,7 @@ public class LobbyController implements Initializable {
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId()) .get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatName()); .getBoatName());
controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId()) controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatType()); .getBoatType().toString());
return customizationDialog; return customizationDialog;
} }
@@ -122,7 +122,7 @@ public class BoatCustomizeController implements Initializable{
} }
public void setCurrentBoat(String boatType) { public void setCurrentBoat(String boatType) {
currentBoat = boatType; currentBoat = BoatMeshType.valueOf(boatType);
displayCurrentBoat(); displayCurrentBoat();
refreshStatBars(currentBoat); refreshStatBars(currentBoat);
} }
@@ -155,7 +155,7 @@ public class BoatCustomizeController implements Initializable{
boatPane.getChildren().add(group); boatPane.getChildren().add(group);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue()); BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets()); group.getChildren().add(bo.getAssets());
refreshStatBars(bo); refreshStatBars(currentBoat);
} }
private void generateMaxStats() { private void generateMaxStats() {
@@ -172,9 +172,9 @@ public class BoatCustomizeController implements Initializable{
} }
} }
private void refreshStatBars(BoatModel bo) { private void refreshStatBars(BoatMeshType bo) {
speedBar.setProgress((bo.getMeshType().maxSpeedMultiplier) / maxSpeedMultiplier); speedBar.setProgress((bo.maxSpeedMultiplier) / maxSpeedMultiplier);
accelBar.setProgress(bo.getMeshType().accelerationMultiplier / maxAcceleration); accelBar.setProgress(bo.accelerationMultiplier / maxAcceleration);
handleBar.setProgress(bo.getMeshType().turnStep / maxTurnRate); handleBar.setProgress(bo.turnStep / maxTurnRate);
} }
} }
+1
View File
@@ -13,6 +13,7 @@ import seng302.model.ServerYacht;
import seng302.visualiser.ClientToServerThread; import seng302.visualiser.ClientToServerThread;
/** /**
*
* Created by kre39 on 7/08/17. * Created by kre39 on 7/08/17.
*/ */
public class ToggleSailSteps { public class ToggleSailSteps {