aliens have damage!

This commit is contained in:
2010-08-31 15:38:24 +04:00
parent 86e24ec276
commit 63a8de6c35
9 changed files with 127 additions and 48 deletions

30
map.cpp
View File

@@ -80,27 +80,44 @@ void Map::removeAliensPath()
bool Map::addTowerOnMap(int playerId, QPoint pos)
{
qDebug() << pos;
//qDebug() << pos;
if (playerId < 0 || playerId > players) return false;
QRect r(QPoint(),mapSize);
if (!r.contains(pos)) return false;
if (Cells[pos.x()][pos.y()]==Player+playerId)
if (!r.contains(pos) ||
!r.contains(pos+QPoint(1,0)) ||
!r.contains(pos+QPoint(0,1)) ||
!r.contains(pos+QPoint(1,1))) return false;
if (Cells[pos.x()][pos.y()]==Player+playerId &&
Cells[pos.x()+1][pos.y()]==Player+playerId &&
Cells[pos.x()][pos.y()+1]==Player+playerId &&
Cells[pos.x()+1][pos.y()+1]==Player+playerId)
{
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId;
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId;
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId;
for (int i=0; i<Starts.size(); i++) {
for (int j=0; j<Finishs.size(); j++) {
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
qDebug("AAAAAA");
Cells[pos.x()][pos.y()]=Player+playerId;
Cells[pos.x()+1][pos.y()]=Player+playerId;
Cells[pos.x()][pos.y()+1]=Player+playerId;
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
return false;
}
}
}
return true;
}
if (Cells[pos.x()][pos.y()]==AlienPath+playerId)
if (Cells[pos.x()][pos.y()]==AlienPath+playerId &&
Cells[pos.x()+1][pos.y()]==AlienPath+playerId &&
Cells[pos.x()][pos.y()+1]==AlienPath+playerId &&
Cells[pos.x()+1][pos.y()+1]==AlienPath+playerId)
{
Cells[pos.x()][pos.y()]=PlayerTower-playerId;
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId;
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId;
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId;
// bool ok=true;
// for (int i=0; i<Starts.size(); i++)
// for (int j=0; j<Finishs.size(); j++)
@@ -121,6 +138,9 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
if (!pathOK)
{
Cells[pos.x()][pos.y()]=AlienPath+playerId;
Cells[pos.x()+1][pos.y()]=AlienPath+playerId;
Cells[pos.x()][pos.y()+1]=AlienPath+playerId;
Cells[pos.x()+1][pos.y()+1]=AlienPath+playerId;
emit recreateAlienPath(pathOK);
return false;
}