Skip to content
Snippets Groups Projects
Commit 2f4a9130 authored by keyno10's avatar keyno10
Browse files

Start on visible health box

parent 41530151
No related branches found
No related tags found
No related merge requests found
...@@ -9,9 +9,9 @@ public class Health { ...@@ -9,9 +9,9 @@ public class Health {
private final ArrayList<Integer> healthBoxes = new ArrayList<>(); private final ArrayList<Integer> healthBoxes = new ArrayList<>();
private SimpleIntegerProperty numberOfHealth = new SimpleIntegerProperty(0); private SimpleIntegerProperty numberOfHealth = new SimpleIntegerProperty(0);
private SimpleIntegerProperty bashing = new SimpleIntegerProperty(0); private int bashing = 0;
private SimpleIntegerProperty lethal = new SimpleIntegerProperty(0); private int lethal = 0;
private SimpleIntegerProperty agg = new SimpleIntegerProperty(0); private int agg = 0;
/** /**
* @param base Basic health boxes * @param base Basic health boxes
...@@ -63,13 +63,13 @@ public class Health { ...@@ -63,13 +63,13 @@ public class Health {
sort(); sort();
//If new health levels lower than current damage, resolve //If new health levels lower than current damage, resolve
if(bashing.getValue() > numberOfHealth.get()) { if(bashing > numberOfHealth.get()) {
bashingDamage(0); bashingDamage(0);
} }
if(lethal.getValue() > numberOfHealth.get()) { if(lethal > numberOfHealth.get()) {
lethalDamage(0); lethalDamage(0);
} }
if(agg.getValue() > numberOfHealth.get()) { if(agg > numberOfHealth.get()) {
aggDamage(0); aggDamage(0);
} }
} }
...@@ -78,11 +78,11 @@ public class Health { ...@@ -78,11 +78,11 @@ public class Health {
* Take bashing damage * Take bashing damage
*/ */
public void bashingDamage(int damage) { public void bashingDamage(int damage) {
if(bashing.getValue() + damage > numberOfHealth.get()) { if(bashing + damage > numberOfHealth.get()) {
lethalDamage(bashing.getValue() + damage - numberOfHealth.get()); bashing = numberOfHealth.get();
bashing.set(numberOfHealth.get()); lethalDamage(bashing + damage - numberOfHealth.get());
} else { } else {
bashing.add(damage); bashing += damage;
} }
} }
...@@ -90,14 +90,14 @@ public class Health { ...@@ -90,14 +90,14 @@ public class Health {
* Take lethal damage * Take lethal damage
*/ */
public void lethalDamage(int damage) { public void lethalDamage(int damage) {
if(lethal.getValue() + damage > numberOfHealth.get()) { if(lethal + damage > numberOfHealth.get()) {
aggDamage(lethal.getValue() + damage - numberOfHealth.get()); lethal = numberOfHealth.get();
lethal.set(numberOfHealth.get()); aggDamage(lethal + damage - numberOfHealth.get());
} else { } else {
lethal.add(damage); lethal += damage;
} }
if(bashing.getValue() < lethal.getValue()) { if(bashing < lethal) {
bashing.set(lethal.getValue()); bashing = lethal;
} }
} }
...@@ -105,14 +105,14 @@ public class Health { ...@@ -105,14 +105,14 @@ public class Health {
* Take agg damage * Take agg damage
*/ */
public void aggDamage(int damage) { public void aggDamage(int damage) {
if(agg.getValue() + damage > numberOfHealth.get()) { if(agg + damage > numberOfHealth.get()) {
death(agg.getValue() + damage - numberOfHealth.get()); agg = numberOfHealth.get();
agg.set(numberOfHealth.get()); death(agg + damage - numberOfHealth.get());
} else { } else {
agg.add(damage); agg += damage;
} }
if(lethal.getValue() < agg.getValue()) { if(lethal < agg) {
lethalDamage(agg.getValue() - lethal.getValue()); lethal = agg;
} }
} }
...@@ -120,23 +120,25 @@ public class Health { ...@@ -120,23 +120,25 @@ public class Health {
* When agg damage == health * When agg damage == health
*/ */
public void death(int damage) { public void death(int damage) {
System.out.println("Overkilled by "+damage);
} }
/** /**
* Get various properties * Assorted getting list
*/ */
public SimpleIntegerProperty getNumberOfHealth() { public SimpleIntegerProperty getNumberOfHealth() {
return numberOfHealth; return numberOfHealth;
} }
public SimpleIntegerProperty getBashing() { public int getBashing() {
return bashing; return bashing;
} }
public SimpleIntegerProperty getLethal() { public int getLethal() {
return lethal; return lethal;
} }
public SimpleIntegerProperty getAgg() { public int getAgg() {
return agg; return agg;
} }
public ArrayList<Integer> getHealthBoxes() {
return healthBoxes;
}
} }
...@@ -3,33 +3,104 @@ package UI; ...@@ -3,33 +3,104 @@ package UI;
import Character.Health; import Character.Health;
import Character.CharacterInterface; import Character.CharacterInterface;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import java.util.ArrayList;
public class HealthBar extends HBox { public class HealthBar extends HBox {
private final Health health; private final Health health;
private final Text bashingCurrent = new Text();
private final Text lethalCurrent = new Text();
private final Text aggCurrent = new Text();
private final TextFlow visualHealthBoxes = new TextFlow();
public HealthBar() { public HealthBar() {
health = CharacterInterface.getHealth(); health = CharacterInterface.getHealth();
healthTypeColumn();
currentHealthColumn();
this.getChildren().add(visualHealthBoxes);
} }
/** /**
* Create health type labels * Create health type labels
*/ */
private void healthTypeLabels() { private void healthTypeColumn() {
VBox typeColumn = new VBox();
this.getChildren().add(typeColumn);
Text maxLabel = new Text("Max");
Text bashingLabel = new Text("Bashing");
Text lethalLabel = new Text("Lethal");
Text aggLabel = new Text("Agg");
typeColumn.getChildren().add(maxLabel);
typeColumn.getChildren().add(bashingLabel);
typeColumn.getChildren().add(lethalLabel);
typeColumn.getChildren().add(aggLabel);
} }
/** /**
* Create current health labels * Create current health labels
*/ */
private void currentHealthLabels() { private void currentHealthColumn() {
//Create VBox and add to health bar
VBox currentColumn = new VBox();
this.getChildren().add(currentColumn);
//Create & add max health
Text maxCurrent = new Text();
maxCurrent.textProperty().bind(health.getNumberOfHealth().asString());
currentColumn.getChildren().add(maxCurrent);
//Add bashing, lethal & agg, then update
currentColumn.getChildren().add(bashingCurrent);
currentColumn.getChildren().add(lethalCurrent);
currentColumn.getChildren().add(aggCurrent);
updateHealthColumn();
} }
/** /**
* Create visual health bar * Update current health values
*/ */
public void updateHealthColumn() {
bashingCurrent.setText(String.valueOf(health.getBashing() - health.getLethal()));
lethalCurrent.setText(String.valueOf(health.getLethal() - health.getAgg()));
aggCurrent.setText(String.valueOf(health.getAgg()));
}
/** /**
* Update visual health bar * Update visual health bar
*/ */
private void updateVisualHealthBar() {
//Clear previous bar & get health boxes
visualHealthBoxes.getChildren().clear();
ArrayList<Integer> boxes = health.getHealthBoxes();
//Loop through boxes
for(int i=0 ; i < boxes.size() ; i++) {
//colour it normal
//while i <= bashing, colour it bashing
//while i <= lethal, colour it lethal
//while i <= agg, colour it agg
}
}
/**
* Change max
*/
/**
* Change bashing
*/
/**
* Change lethal
*/
/**
* Change agg
*/
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment