last changes

This commit is contained in:
2020-06-15 22:22:46 +03:00
parent 5f405ca403
commit 259f321df4
53 changed files with 3368 additions and 842 deletions

View File

@@ -48,6 +48,8 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
scene->addItem(tw.item);
gameData->curTowers.insert(tw.pos,tw);
p->money -= tw.src->cost;
p->stats.spend_money += tw.src->cost;
p->stats.builded_towers++;
return true;
}
return false;
@@ -106,13 +108,20 @@ void Towers::update()
{
AlienType al = gameData->aliens->curAliens.value(gameData->players.at(i->PlayerId)->selectAlienId);
if (distance2(al.pos+QPointF(0.5f,0.5f), i->pos) < rad2) i->aim = al.id;
else i->aim = -1;
}
if (i->aim == 0)
{
qDebug() << tr("err tower") << i->pos << gameData->players.at(i->PlayerId)->selectAlienId;
qFatal("tower has incorrect aim = 0");
return;
}
if (i->aim < 0)
{
for (QHash<int, AlienType>::iterator j = gameData->aliens->curAliens.begin(); j != gameData->aliens->curAliens.end(); ++j)
{
float dist = distance2(i->pos, (*j).pos+QPointF(0.5f,0.5f));
if (dist < rad2) i->aim = (*j).id;
float dist = distance2(i->pos, j->pos+QPointF(0.5f,0.5f));
if (dist < rad2) i->aim = j->id;
}
}
if (i->aim > 0)
@@ -144,6 +153,7 @@ bool Towers::morphTower(QPoint id, int index)
// tower_killed(id);
TowerType & t(gameData->curTowers[id]);
gameData->players[t.PlayerId]->money -= t.src->morphs[index].cost;
gameData->players[t.PlayerId]->stats.spend_money += t.src->morphs[index].cost;
t.src = t.src->morphs[index].morph;
t.build = 0;
t.reload = 0;