Merge remote-tracking branch 'remotes/origin/master' into raceView_UI

# Conflicts:
#	racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java
#	racevisionGame/src/main/resources/visualiser/scenes/newRaceView.fxml
This commit is contained in:
hba56
2017-09-28 11:32:25 +13:00
31 changed files with 622 additions and 33 deletions
@@ -103,6 +103,11 @@ public class Boat extends Collider {
*/
private boolean isColliding = false;
/**
* Amount of health boat currently has, between 0 and 100
*/
private double health;
/**
* Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table.
*
@@ -113,6 +118,7 @@ public class Boat extends Collider {
public Boat(int sourceID, String name, String country) {
this.sourceID = sourceID;
this.health = 100;
this.setName(name);
this.setCountry(country);
@@ -419,6 +425,8 @@ public class Boat extends Collider {
@Override
public void onCollisionEnter(Collision e) {
if(e.getBearing().degrees() > 270 || e.getBearing().degrees() < 90) {
// Deplete health
e.getBoat().updateHealth(-5);
// Notify observers of collision
this.setChanged();
notifyObservers(e);
@@ -432,4 +440,22 @@ public class Boat extends Collider {
public void setColliding(boolean colliding) {
isColliding = colliding;
}
public double getHealth() {
return health;
}
public void setHealth(double health) {
this.health = health;
}
/**
* Add a given amount of HP to boat health
* @param delta amount of HP to add
*/
public void updateHealth(double delta) {
health += delta;
if(health < 0) health = 0;
else if(health > 100) health = 100;
}
}
@@ -97,6 +97,7 @@ public class Mark extends Collider{
@Override
public void onCollisionEnter(Collision e) {
e.getBoat().updateHealth(-10);
this.setChanged();
notifyObservers(e);
}