build_towers
This commit is contained in:
11
towers.cpp
11
towers.cpp
@@ -22,6 +22,11 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
||||
qCritical("ERROR out of towers range");
|
||||
return false;
|
||||
}
|
||||
QRect alrec(pos,QSize(1,1));
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
if (alrec.contains((*i).pos.toPoint())) return false;
|
||||
}
|
||||
TowerType tw;
|
||||
tw.src = srcId;
|
||||
tw.imgType = gameData->players.at(playerId)->srcTowers.at(srcId).imgType;
|
||||
@@ -46,7 +51,11 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
||||
|
||||
void Towers::delTower(QPoint pos)
|
||||
{
|
||||
gameData->curTowers.remove(pos);
|
||||
if (gameData->curTowers.contains(pos))
|
||||
{
|
||||
gameData->map->delTowerOnMap(gameData->curTowers.value(pos).PlayerId,pos);
|
||||
gameData->curTowers.remove(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user