aliens have damage!
This commit is contained in:
37
splashes.cpp
37
splashes.cpp
@@ -96,7 +96,9 @@ void Splashes::addSplash(QPoint curTowerId)
|
||||
spl.trigsOnTimer.append(tot);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
qDebug() << "t=" << src.triggerIndexes.size() << "d=" << spl.trigsOnDest.size();
|
||||
gameData->curSplashes.insert(spl.id,spl);
|
||||
nextId++;
|
||||
}
|
||||
@@ -137,6 +139,23 @@ void Splashes::update()
|
||||
for (int k=0; k<spl.trigsOnDest.size(); k++)
|
||||
{
|
||||
// TODO: activate trigger
|
||||
srcTriggerType strig = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).triggers.at(spl.trigsOnDest.at(k).src);
|
||||
if (strig.delParent) deadIndexes.push_back(spl.id);
|
||||
if (strig.damage > 0)
|
||||
{
|
||||
if (!(strig.radius > 0))
|
||||
{
|
||||
if (!badAl)
|
||||
{
|
||||
float hh = gameData->curAliens[spl.AlienId].health -= strig.damage;
|
||||
if (hh < 0)
|
||||
gameData->curAliens.remove(spl.AlienId);
|
||||
qDebug() << "health=" << hh;
|
||||
}
|
||||
} else {
|
||||
processTrigger(strig,spl.pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
|
||||
@@ -168,3 +187,21 @@ void Splashes::delSplash(int Id)
|
||||
{
|
||||
gameData->curSplashes.remove(Id);
|
||||
}
|
||||
|
||||
|
||||
void Splashes::processTrigger(srcTriggerType srctrig, QPointF pos)
|
||||
{
|
||||
qDebug("trig proc");
|
||||
QList <int> dead;
|
||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
||||
{
|
||||
if (distance2(pos, (*i).pos) < srctrig.radius*srctrig.radius)
|
||||
{
|
||||
(*i).health -= srctrig.damage;
|
||||
//qDebug() << "health=" << hh;
|
||||
if ((*i).health < 0) dead.append((*i).id);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<dead.size(); ++i)
|
||||
gameData->curAliens.remove(dead.at(i));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user