-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoss.java
More file actions
87 lines (79 loc) · 2.95 KB
/
Boss.java
File metadata and controls
87 lines (79 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import java.util.ArrayList;
import javafx.application.Platform;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.util.Duration;
public class Boss extends VBox {
private int health;
private int bossHealth;
private ArrayList<String> words;
private ArrayList<String> meanings;
private ArrayList<Double> weights;
private boolean mcq;
private int maxBoss;
private int max;
private final ProgressBar bossHp;
private final ProgressBar playerHp;
private final DoubleProperty bossProgress = new SimpleDoubleProperty(1);
private final DoubleProperty playerProgress = new SimpleDoubleProperty(1);
private Label playerHpUI;
private Label bossHpUI;
private EXPBarUI xpBar;
public Boss(ArrayList<String> w, ArrayList<String> m, ArrayList<Double> weight, EXPBarUI exp) {
setSpacing(10);
setPadding(new Insets(16));
health = 5;
bossHealth = 5;
max = health;
maxBoss = bossHealth;
words = w;
meanings = m;
weights = weight;
xpBar = exp;
bossHp = new ProgressBar();
playerHp = new ProgressBar();
bossHp.progressProperty().bind(bossProgress);
playerHp.progressProperty().bind(playerProgress);
bossHp.getStyleClass().add("boss-health-bar");
playerHp.getStyleClass().add("player-health-bar");
playerHpUI = new Label("Player HP: " + health + "/" + max);
bossHpUI = new Label("Boss HP: " + bossHealth + "/" + maxBoss);
Label title = new Label("Boss Battle");
Label info = new Label("Cards: " + (words != null ? words.size() : 0));
HBox playerBar = new HBox(playerHpUI, playerHp);
HBox bossBar = new HBox(bossHpUI, bossHp);
// Learn learnView = new Learn(words, weights, meanings, xpBar);
getChildren().addAll(title, info, playerBar, bossBar);
}
public void updateHp(Label progressUI, int hp, String object, int m) {
progressUI.setText(object + " HP: " + hp + "/" + m);
}
public void dmgBoss() {
bossHealth--;
bossProgress.set((double) bossHealth/maxBoss);
updateHp(bossHpUI, bossHealth, "Boss", maxBoss);
}
public void dmgPlayer() {
health--;
playerProgress.set((double) health/max);
updateHp(playerHpUI, health, "Player", max);
}
public boolean checkHp(int hp) {
return hp == 0;
}
public void endGame() {
//finish animations and delete boss off the screen.
}
}