aliens have damage!
This commit is contained in:
30
map.cpp
30
map.cpp
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user