-
Notifications
You must be signed in to change notification settings - Fork 0
/
Powerup.java
54 lines (52 loc) · 1.42 KB
/
Powerup.java
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
import javafx.scene.image.*;
import java.util.ArrayList;
public class Powerup extends BasicBlock {
int p_type;
boolean on = false;
boolean avail = false;
public Powerup(Location l,int t) {
super(l, BasicBlock.BlockType.POWERUP);
p_type = t;
if (p_type == 1){
image = new Image("steel.png"); // change this! GRENDADE
} else if (p_type == 2){
image = new Image("steel.png"); // change this!
} else if (p_type == 3){
image = new Image("steel.png"); // change this!
}
iv = new ImageView(image);
iv.setX(l.getCol());
iv.setY(l.getRow());
iv.setFitHeight(40);
iv.setFitWidth(40);
}
public void newPowerup(Location l,int t) {
p_type = t;
location.setLocation(l);
if (p_type == 1){
image = new Image("grenade.png"); // change this! GRENDADE
} else if (p_type == 2){
image = new Image("helmet1.png"); // change this!
} else if (p_type == 3){
image = new Image("timer.png"); // change this!
}
iv.setImage(image);
iv.setX(l.getCol());
iv.setY(l.getRow());
iv.setFitHeight(40);
iv.setFitWidth(40);
}
public void impact(int f) {
if (p_type == 1){
ArrayList<Enemy> enem = Data.getData().enem;
for (int x = 0; x < enem.size(); x++) {
enem.get(x).impact(0);
}
} else if (p_type == 2) {
Data.getData().player.helmet = true;
Data.getData().player.iv.setImage(new Image("helmet.png"));
} else if (p_type == 3) {
Data.getData().timefreeze(1);
}
}
}