private Vector2f position;
@Override
public void doCommand() {
GunTower gt = new GunTower(this.position.x, this.position.y, this.player);
// Can the player allow it ?
if(player.getBank().getMoney() > gt.getBuyingPrice()) {
// we add the tower to the game
Game.getInstance().getTowerManager().addTower(gt);
if (this.player instanceof RealPlayer) {
((RealPlayer)this.player).setBuildingTower(false);
}
gt.setBorder(BorderFactory.createLineBorder(Color.black));
gt.setContentAreaFilled(false);
gt.setBounds((int)gt.getPosition().x, (int)gt.getPosition().y, 40, 40);
gt.setOpaque(true);
try
{
gt.setIcon(new ImageIcon(ImageIO.read(new File(Theme.pathImageTower))));
gt.setBackground(Color.RED);
}
catch (IOException e1)
{
System.out.println(e1);
}
// we add the tower to the window
AppliWindow.getInstance().getContent().add(gt);
AppliWindow.getInstance().giveFocusToPanel();
// we remove the money
this.player.getBank().setMoney(this.player.getBank().getMoney() - gt.getBuyingPrice());
} else {
System.out.println("Out of Money sorry, poor !");
}
}