Update JokerPanel.java
This commit is contained in:
parent
cc8df22352
commit
5e18d3ba44
1 changed files with 17 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import game.Game;
|
import game.Game;
|
||||||
import game.map.Castle;
|
import game.map.Castle;
|
||||||
|
|
@ -56,7 +57,7 @@ public class JokerPanel extends JPanel implements MouseListener{
|
||||||
jokers[index] = j;
|
jokers[index] = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playJoker(JokerTypes joker) {
|
public void playJoker(int index) {
|
||||||
if(game.getRound() < 2)
|
if(game.getRound() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -99,21 +100,27 @@ public class JokerPanel extends JPanel implements MouseListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintJokers(Graphics g) {
|
public void paintJokers(Graphics g) {
|
||||||
System.out.println("X: " + e.getX() + " Y: " + e.getY());
|
if(jokers == null)
|
||||||
if(e.getX() <= 41 && jokers[0] == JokerTypes.ADD_TROOPS) {
|
return;
|
||||||
playJoker(0);
|
|
||||||
} else
|
|
||||||
playJoker(1);
|
|
||||||
|
for(int i = 0; i < jokers.length; i++) {
|
||||||
|
System.out.print("i: " + i + jokers[i] + " ");
|
||||||
|
g.drawImage(resources.getJokers()[jokers[i].ordinal()], 9 + 32 * i + 10 * i, 5, 32, 32, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
playJoker(JokerTypes.ADD_TROOPS);
|
System.out.println("X: " + e.getX() + " Y: " + e.getY());
|
||||||
for(JokerTypes j : jokers) {
|
if(e.getX() <= 41 && jokers[0] == JokerTypes.ADD_TROOPS) {
|
||||||
System.out.println(j.ordinal());
|
playJoker(0);
|
||||||
}
|
} else
|
||||||
|
playJoker(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue