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.
if (yacht.getSailIn()) {
if (currentVelocity < maxBoatSpeed - 500) {
yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAcceleration());
yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAccelerationMultiplier());
} else if (currentVelocity > maxBoatSpeed + 500) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration());
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
} else {
yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAcceleration());
yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAccelerationMultiplier());
}
} else {
if (currentVelocity > 3000) {
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration());
yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier());
} else if (currentVelocity > 100) {
yacht.changeVelocity((-currentVelocity / 50) * yacht.getAcceleration());
yacht.changeVelocity((-currentVelocity / 50) * yacht.getAccelerationMultiplier());
} else if (currentVelocity <= 100) {
yacht.setCurrentVelocity(0d);
}
+9 -5
View File
@@ -29,7 +29,8 @@ public class ServerYacht {
private BoatMeshType boatType;
private Double turnStep = 5.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 String hullID; //matches HullNum in the XML spec.
private String shortName;
@@ -133,7 +134,7 @@ public class ServerYacht {
* @param amount the amount by which to adjust the boat heading.
*/
public void adjustHeading(Double amount) {
Double newVal = heading + amount;
Double newVal = heading + (amount * turnStepMultiplier);
lastHeading = heading;
heading = (double) Math.floorMod(newVal.longValue(), 360L);
}
@@ -272,7 +273,7 @@ public class ServerYacht {
private void turnTowardsHeading(Double newHeading) {
Double newVal = heading - newHeading;
if (Math.floorMod(newVal.longValue(), 360L) > 180) {
adjustHeading(turnStep / 5);
adjustHeading(turnStep / 5);
} else {
adjustHeading(-turnStep / 5);
}
@@ -426,6 +427,9 @@ public class ServerYacht {
}
public void setBoatType(BoatMeshType boatType) {
this.accelerationMultiplier = boatType.accelerationMultiplier;
this.maxSpeedMultiplier = boatType.maxSpeedMultiplier;
this.turnStepMultiplier = boatType.turnStep;
this.boatType = boatType;
}
@@ -433,8 +437,8 @@ public class ServerYacht {
return maxSpeedMultiplier;
}
public Double getAcceleration(){
return acceleration;
public Double getAccelerationMultiplier(){
return accelerationMultiplier;
}
@@ -131,7 +131,7 @@ public class LobbyController implements Initializable {
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatName());
controller.setCurrentBoat(this.playerBoats.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId())
.getBoatType());
.getBoatType().toString());
return customizationDialog;
}
@@ -122,7 +122,7 @@ public class BoatCustomizeController implements Initializable{
}
public void setCurrentBoat(String boatType) {
currentBoat = boatType;
currentBoat = BoatMeshType.valueOf(boatType);
displayCurrentBoat();
refreshStatBars(currentBoat);
}
@@ -155,7 +155,7 @@ public class BoatCustomizeController implements Initializable{
boatPane.getChildren().add(group);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
refreshStatBars(bo);
refreshStatBars(currentBoat);
}
private void generateMaxStats() {
@@ -172,9 +172,9 @@ public class BoatCustomizeController implements Initializable{
}
}
private void refreshStatBars(BoatModel bo) {
speedBar.setProgress((bo.getMeshType().maxSpeedMultiplier) / maxSpeedMultiplier);
accelBar.setProgress(bo.getMeshType().accelerationMultiplier / maxAcceleration);
handleBar.setProgress(bo.getMeshType().turnStep / maxTurnRate);
private void refreshStatBars(BoatMeshType bo) {
speedBar.setProgress((bo.maxSpeedMultiplier) / maxSpeedMultiplier);
accelBar.setProgress(bo.accelerationMultiplier / maxAcceleration);
handleBar.setProgress(bo.turnStep / maxTurnRate);
}
}