-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterfaceCaixa.java
151 lines (123 loc) · 5.46 KB
/
InterfaceCaixa.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import javax.swing.*;
import java.awt.*;
import java.io.Serializable;
public class InterfaceCaixa extends JPanel implements Serializable {
private CardLayout maincardLayout = new CardLayout();
private JPanel mainCardPanel = new JPanel(maincardLayout);
private JPanel battleLayoutPanel = new JPanel(new GridLayout(1, 2));
private CardLayout leftcardLayout = new CardLayout();
private JPanel leftComponent = new JPanel(leftcardLayout);
private JLabel msgLabel = new JLabel();
private Font Fonte = DefinirFonte.fonte();
public InterfaceCaixa(Game frame) {
Player.setInterfaceCaixa(this);
Enemy.setInterfaceCaixa(this);
Enemy.setGameFrame(frame);
msgTexto("O que " + Player.pokemonSelecionado.getNome().toUpperCase(), "vai fazer?");
msgLabel.setIcon(new ImageIcon("assets/battleElements/ataque background.png"));
leftComponent.add(msgLabel, "MessageLabel");
mainCardPanel.add(battleLayoutPanel, "BattleLayoutPanel");
leftComponent.add(new Poderes(this), "poderes");
Options options = new Options(frame, this);
// Adicionando os componentes ao painel principal
battleLayoutPanel.add(leftComponent);
battleLayoutPanel.add(options);
// Defina um layout para o JPanel principal
setLayout(new BorderLayout());
add(mainCardPanel, BorderLayout.CENTER);
}
public void mudarInterfaceLayout(String nomeLayout) {
System.out.println("Mudando interface para modo " + nomeLayout);
maincardLayout.show(mainCardPanel, nomeLayout);
}
public void mudarInterfaceBattleLayout(String nomeLayout) {
System.out.println("Mudando interface para modo " + nomeLayout);
leftcardLayout.show(leftComponent, nomeLayout);
}
// mostra qual ataque foi usado por 3 segundos e depois volta para a tela de batalha
public void mostrarAtaque() {
msgLabel.setIcon(new ImageIcon("assets/battleElements/ataque background.png"));
mainCardPanel.add(msgLabel, "MsgLabel");
maincardLayout.show(mainCardPanel, "MsgLabel");
revalidate();
Timer timer = new Timer(1000, e -> {
mainCardPanel.remove(msgLabel);
msgLabel.removeAll();
maincardLayout.show(mainCardPanel, "BattleLayoutPanel");
revalidate();
repaint();
});
timer.setRepeats(false);
timer.start();
}
public void mostrarAtaqueInimigo() {
String[] poderes = {"scratch", "quick attack", "tackle", "bite"};
String nomeAtaque = poderes[(int) (Math.random() * poderes.length)];
msgTexto(Enemy.inimigoAtual.getNome().toUpperCase() + " usou", nomeAtaque.toUpperCase() + "!");
msgLabel.setIcon(new ImageIcon("assets/battleElements/ataque background.png"));
mainCardPanel.add(msgLabel, "MsgLabel");
maincardLayout.show(mainCardPanel, "MsgLabel");
revalidate();
Timer timer = new Timer(1000, e -> {
mainCardPanel.remove(msgLabel);
msgLabel.removeAll();
maincardLayout.show(mainCardPanel, "BattleLayoutPanel");
revalidate();
repaint();
});
timer.setRepeats(false);
timer.start();
}
public void mostrarDerrotaInimigo() {
msgTexto(Enemy.inimigoAtual.getNome().toUpperCase() + " inimigo", "foi derrotado!");
msgLabel.setIcon(new ImageIcon("assets/battleElements/ataque background.png"));
mainCardPanel.add(msgLabel, "MsgLabel");
maincardLayout.show(mainCardPanel, "MsgLabel");
revalidate();
Timer timer = new Timer(1000, e -> {
mainCardPanel.remove(msgLabel);
msgLabel.removeAll();
maincardLayout.show(mainCardPanel, "BattleLayoutPanel");
revalidate();
repaint();
});
timer.setRepeats(false);
timer.start();
}
public void mostrarDerrotaPlayer() {
msgTexto(Player.pokemonSelecionado.getNome().toUpperCase() + " foi derrotado!", "");
msgLabel.setIcon(new ImageIcon("assets/battleElements/ataque background.png"));
mainCardPanel.add(msgLabel, "MsgLabel");
maincardLayout.show(mainCardPanel, "MsgLabel");
revalidate();
Timer timer = new Timer(1000, e -> {
mainCardPanel.remove(msgLabel);
msgLabel.removeAll();
maincardLayout.show(mainCardPanel, "BattleLayoutPanel");
revalidate();
repaint();
});
timer.setRepeats(false);
timer.start();
}
public void limparMsgTexto() {
msgLabel.removeAll();
revalidate();
repaint();
}
public void msgTexto(String texto0, String texto1) {
JLabel linha0 = new JLabel(texto0);
JLabel linha1 = new JLabel(texto1);
linha0.setFont(Fonte.deriveFont(Font.PLAIN,60f));
linha1.setFont(Fonte.deriveFont(Font.PLAIN,60f));
linha0.setBounds(50, 35, 800, 60);
linha1.setBounds(50, 95, 800, 60);
linha0.setForeground(Color.WHITE);
linha1.setForeground(Color.WHITE);
msgLabel.add(linha0);
msgLabel.add(linha1);
}
public JLabel getMsgLabel() {
return msgLabel;
}
}