void GenerateShit::Reset() { qDebug() << "Reset "; for(int i = shits.size() - 1; i >= 0; i--) { deleteEnemy(i); } for(int i = shitsCreating.size() - 1; i >= 0; i--) { if(shitsCreating[i] != 0) delete shitsCreating[i]; shitsCreating.remove(i); } }
void GenerateShit::ClearActive() { qDebug() << "ClearActive "; for(int i = shits.size() - 1; i >= 0; i--) { if( shits[i]->isActive() ) deleteEnemy(i); } for(int i = shitsCreating.size() - 1; i >= 0; i--) { if( shitsCreating[i]->isActive() ) { if(shitsCreating[i] != 0) delete shitsCreating[i]; shitsCreating.remove(i); } } }
bool EnemyLegion::checkCollide(Vector3D colliderPosition, int type, int b) { bool collided = false; int buffer = b; for(unsigned int i=0; i<numActiveTroops; i++) { if(((colliderPosition.x>(troops[i]->position.x-buffer)) && (colliderPosition.x<(troops[i]->position.x+buffer))) && ((colliderPosition.y>(troops[i]->position.y-buffer))&&(colliderPosition.y<(troops[i]->position.y+buffer)))) { collided = true; collidedPosition = Vector3D(troops[i]->position.x, troops[i]->position.y); if(type==1) deleteEnemy(i); } } return collided; }
void GenerateShit::checkDelete() { for(int i = 0; i < shits.size(); i++) { if(shits[i]->mastDelete) { if(shits[i]->timeDeath > 3) { #ifdef DEBUG_MODE qDebug() << "delete shit in checkDelete\n"; #endif deleteEnemy(i); } else shits[i]->timeDeath++; } } }
void GenerateShit::CheckBorder() { for(int i = 0; i < shits.size(); i++) { if(!shits[i]->GetActive()) continue; if(shits[i]->pos().x() > 850 || shits[i]->pos().x() < -100) deleteEnemy(i); if(shits[i]->pos().y() > 540) { int pos = qrand() % 25 * ((qrand() % 2 == 0) ? -1 : 1) - 50; shits[i]->SetNotActive(); shits[i]->setY(shits[i]->pos().y() + pos + 50); shits[i]->setZValue(pos); if(!shits[i]->mastDelete) GameInfo::SubstractHealth(shits[i]->GetDamage()); } } }