-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebuffVisu.java
More file actions
83 lines (78 loc) · 1.92 KB
/
DebuffVisu.java
File metadata and controls
83 lines (78 loc) · 1.92 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
import greenfoot.*;
/**
* The visual indicator for debuffs on the mobs
*
* @author James Lu
* @version 1.0
*/
public class DebuffVisu extends Effects
{
private int frame; //current frame of the picture
private int maxFrame; //max frame of the pictures
private Enemy e;
public DebuffVisu(Enemy e){
counter = 0;
this.e = e;
bg = new GreenfootImage (20, 20);
this.setImage (bg);
}
/**
* Sets a debuff on this visualizer <br>
* 0 is stun <br>
* 1 is lightning <br>
* 2 is freeze <br>
* 3 is burn <br>
* 4 is stone
*/
public void setDebuff (int id){
if (id == 0){ //stun
cache = Data.stun;
maxFrame = 6;
}else if (id == 1){ //lightning
cache = Data.air;
maxFrame = 2;
}else if (id == 2){ //freeze
cache = Data.freeze;
maxFrame = 2;
}else if (id == 3){ //burn
cache = Data.burn;
maxFrame = 2;
}else if (id == 4){
cache = Data.stone;
maxFrame = 2;
}
counter = 0;
frame = 1;
show = true;
}
public void act(){
if (show){
if (counter >= 2){
counter = 0;
frame++;
if (frame > maxFrame){
frame = 1;
}
this.setImage (cache[frame-1]);
}
else{
counter++;
}
}else{
this.setImage (bg);
}
}
/**
* Sets the location of the debuff <br>
* The paramaters passed are the x and y values of the enemy
*/
public void changeLocation (int x, int y){
this.setLocation (x, y-10);
}
/**
* Returns the enemy that this debuff belongs to
*/
public Enemy getEnemy(){
return e;
}
}