-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.java
64 lines (52 loc) · 1.66 KB
/
Game.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
import javax.swing.*;
public class Game extends JFrame implements Runnable {
private JPanel painelAtual;
private Player currentPlayer;
static Game game;
public void run() {
Game.game = this;
editar();
}
public void editar() {
setTitle("pokeBattle");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(976, 679);
setResizable(false);
setLocationRelativeTo(null);
new Enemy();
setVisible(true);
boolean saveExists = Player.carregarDados();
if (saveExists) {
Home home = new Home(this);
mudarTela(home);
} else {
Intro intro = new Intro(this);
mudarTela(intro);
}
}
public void setPlayer(Player player) {
this.currentPlayer = player;
}
public Player getPlayer() {
return this.currentPlayer;
}
public void mudarTela(JPanel novoPanel) {
if (painelAtual != null) {
remove(painelAtual);
painelAtual = null;
}
painelAtual = novoPanel;
add(painelAtual);
if (painelAtual instanceof PokemonsBatle) {
PokemonsBatle battlePanel = (PokemonsBatle) painelAtual;
battlePanel.atualizarVidaPlayer();
battlePanel.atualizarVidaInimigo();
} else if (painelAtual instanceof EvolucaoPage) {
EvolucaoPage evolucaoPage = (EvolucaoPage) painelAtual;
evolucaoPage.revalidate();
evolucaoPage.repaint();
}
revalidate();
repaint();
}
}