This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevelSelectionState.java
69 lines (62 loc) · 2.29 KB
/
LevelSelectionState.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
65
66
67
68
69
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
public class LevelSelectionState extends State{
private UIManager uiManager;
private gameState gState;
private Font f,f2;
public LevelSelectionState(Handler handler){
super(handler);
uiManager = new UIManager(handler);
setChanged();
f = new Font("papyrus", Font.BOLD, 24);
f2 = new Font("papyrus", Font.BOLD, 18);
}
public void init(){
handler.getMouseManager().setUIManager(uiManager);
uiManager.addObject(new UIImageButton(handler.getWidth()/2 , handler.getHeight()/2,67,67, Assets.btn_one, new ClickListener(){
public void onClick(){
//handler.getMouseManager().setUIManager(null);
gState = (gameState)handler.getGame().gState;
gState.loadLevel(1,"level1.txt", 180,14);
State.setState(handler.getGame().gState);
handler.getGame().gState.setChanged();
}
}));
uiManager.addObject(new UIImageButton(handler.getWidth()/2 , handler.getHeight()/2 + 90,67,67, Assets.btn_two, new ClickListener(){
public void onClick(){
//handler.getMouseManager().setUIManager(null);
if(handler.getDatabase().hasMedal(1) == true){
gState = (gameState)handler.getGame().gState;
gState.loadLevel(2,"level2.txt", 120,15);
State.setState(handler.getGame().gState);
handler.getGame().gState.setChanged();
}
}
}));
uiManager.addObject(new UIImageButton(handler.getWidth()/2 , handler.getHeight()/2 + 180,67,67, Assets.btn_menu, new ClickListener(){
public void onClick(){
//handler.getMouseManager().setUIManager(null);
State.setState(handler.getGame().mState);
handler.getGame().mState.setChanged();
}
}));
}
public void update(){
uiManager.update();
if(changed){
init();
changed = false;
}
//handler.getMouseManager().setUIManager(null);
}
public void render(Graphics g){
g.drawImage(Assets.Poster,0,0,handler.getWidth(),handler.getHeight(),null);
uiManager.render(g);
g.setColor(Color.white);
g.setFont(f);
g.drawString("Level Selection", handler.getWidth()/2 - 50, handler.getHeight()/2 - 50);
g.setFont(f2);
g.drawString("Menu", handler.getWidth()/2 - 60, handler.getHeight()/2 + 210);
}
}