BuildTowerRoundMessage btrm = (BuildTowerRoundMessage) gm;
Grid grid = this.gameBoard.getGrid((int) btrm.getTowerPosition()
.getX(), (int) btrm.getTowerPosition().getY());
if (grid.isFree()) {
Tower t = TowerFactory.createTower(this, IConstants.Towers
.valueOf(IConstants.Towers.class, btrm.getTowerType()),
grid);
t.setBuilding(true);
t.setBuildTime((int) (btrm.getRoundId() - roundId));
t.setId(btrm.getTowerId());
this.addtower(t);
System.out.println(btrm.getRoundId() - roundId);
}
} else if (gm instanceof UpgradeTowerRoundMessage) {
UpgradeTowerRoundMessage utrm = (UpgradeTowerRoundMessage) gm;
Tower upgradeTower;
// find the tower we want to upgrade
for (Tower tower : towers) {
if (tower.getId() == utrm.getTowerId() && tower.isReady()) {
upgradeTower = tower;
// set UpgradTime
upgradeTower.setUpgradeTime((int) (utrm.getRoundId() - roundId));
break;
}
}
} else if (gm instanceof ChangeStrategyRoundMessage) {
ChangeStrategyRoundMessage csm = (ChangeStrategyRoundMessage) gm;
// find the tower we want to change
for (Tower tower : towers) {
if (tower.getId() == csm.getTowerId() && tower.isReady()) {
FindCreepStrategy fcs = StrategyFactory.getStrategyForName(
csm.getStrategyType(), tower);
fcs.setCreepLock(csm.isLocked());
((AbstractTower) tower).setChangeStrategyTime((int)(csm.getRoundId() - roundId));
((AbstractTower) tower).setSelectedStrategy(fcs);
break;
}
}
} else if (gm instanceof SellTowerRoundMessage) {
SellTowerRoundMessage strm = (SellTowerRoundMessage) gm;
Tower sellTower;
// find the tower we want to sell
for (Tower tower : towers) {
if (tower.getId() == strm.getTowerId() && tower.isReady()) {
sellTower = tower;
sellTower.setSellTime((int) (strm.getRoundId() - roundId));
sellTower.setSelling(true);
break;
}
}
System.out.println(strm.getRoundId() - roundId);
} else if (gm instanceof BuildCreepRoundMessage) {