-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelUpScreen.java
64 lines (59 loc) · 2.46 KB
/
LevelUpScreen.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
55
56
57
58
59
60
61
62
63
64
//To use GUI items
import java.awt.*;
import java.util.*;
public class LevelUpScreen{
//The buttons to level up a specific attribute
ArrayList<Button[]> btn = new ArrayList<Button[]>();
ArrayList<Image> img = new ArrayList<Image>();
int width = 0, height = 0;
void showAll(int widthLimit, int heightLimit, ArrayList<Character> c){
btn.clear();
img.clear();
Button but[] = new Button[]{
new Button("Increase Health"), new Button("Increase Damage"),
new Button("Decrease Ability 1's cooldown"), new Button("Decrease Ability 2's cooldown"),
new Button("Increase Movement Speed"), new Button("Level Up Ability")
};
Button but2[] = new Button[]{
new Button("Increase Health"), new Button("Increase Damage"),
new Button("Decrease Ability 1's cooldown"), new Button("Decrease Ability 2's cooldown"),
new Button("Increase Movement Speed"), new Button("Level Up Ability")
};
Button but3[] = new Button[]{
new Button("Increase Health"), new Button("Increase Damage"),
new Button("Decrease Ability 1's cooldown"), new Button("Decrease Ability 2's cooldown"),
new Button("Increase Movement Speed"), new Button("Level Up Ability")
};
//Add buttons and images
for(int i = 0; i < c.size(); i ++){
img.add(c.get(i).healthyImage);
}
btn.add(but); btn.add(but2); btn.add(but3);
width = (widthLimit - 100 - 10*(c.size()-1))/c.size();
height = (heightLimit - 150 - 10*(btn.get(0).length-1))/btn.get(0).length;
//Set button's positions
for(int i = 0; i < btn.size(); i++){
for(int x = 0; x < btn.get(i).length; x++){
btn.get(i)[x].setBounds(50 + (width + 10)*i, 100 + (height + 10)*x, width, height);
}
}
//Set them visible
for(int i = 0; i < btn.size(); i++){
for(int x = 0; x < btn.get(i).length; x++){
btn.get(i)[x].setVisible(true);
}
}
}
void hideAll(){
for(int i = 0; i < btn.size(); i++){
for(int x = 0; x < btn.get(i).length; x++){
btn.get(i)[x].setVisible(false);
}
}
}
public void paint(Graphics g){
for(int i = 0; i < btn.size(); i++){
g.drawImage(img.get(i), width/2 + 50 + (width*i), 40, null);
}
}
}