void Enemy::addDamage(int dmg) { shield -= dmg; if (shield <= 0) { // Destroyed. addBonuses(); manager->addScore(ENEMY_TYPE_SCORE[type->type]); if (isBoss) { addFragments(15, 0, 0.1, rand.nextSignedFloat(1)); SoundManager::playSe(SoundManager::BOSS_DESTROYED); manager->setScreenShake(20, 0.05); manager->clearBullets(); removeTopBullets(); dstCnt = DESTROYED_CNT; } else { float d; if (type->type == EnemyType::SMALL) { d = moveBullet->bullet->deg; SoundManager::playSe(SoundManager::ENEMY_DESTROYED); } else { d = rand.nextSignedFloat(1); SoundManager::playSe(SoundManager::LARGE_ENEMY_DESTROYED); } addFragments(type->type * 4 + 2, 0, 0.04, d); remove(); } } damaged = true; }
void LibraryModel::loadFromDatabase() { addFragments(dbEngine_->template list<Fragment>()); }
void Enemy::move() { EnemyType::isExist[type->id] = true; if (!isBoss) { pos.x = moveBullet->bullet->pos.x; pos.y = moveBullet->bullet->pos.y; } else { moveBoss(); } if (topBullet) { topBullet->bullet->pos.x = pos.x; topBullet->bullet->pos.y = pos.y; } damaged = false; for (int i = 0; i < type->batteryNum; ++i) { const BatteryType* bt = &(type->batteryType[i]); Battery* b = &(battery[i]); b->damaged = false; for (int j = 0; j < bt->batteryNum; ++j) { if (b->topBullet[j]) { b->topBullet[j]->bullet->pos.x = pos.x + bt->batteryPos[j].x; b->topBullet[j]->bullet->pos.y = pos.y + bt->batteryPos[j].y; } } } if (!isBoss) { if (field->checkHit(pos)) { remove(); return; } if (pos.y < -field->size.y / 4) { removeTopBullets(); } else { controlFireCnt(); } } else { float mtr; if (appCnt > 0) { if (z < 0) z -= APPEARANCE_Z / 60; appCnt--; mtr = 1.0 - (float)appCnt / APPEARANCE_CNT; } else if (dstCnt > 0) { addFragments(1, z, 0.05, rand.nextSignedFloat(M_PI)); manager->clearBullets(); z += DESTROYED_Z / 60; dstCnt--; if (dstCnt <= 0) { addFragments(25, z, 0.4, rand.nextSignedFloat(M_PI)); manager->setScreenShake(60, 0.01); remove(); manager->setBossShieldMeter(0, 0, 0, 0, 0, 0); return; } mtr = static_cast<float>(dstCnt) / DESTROYED_CNT; } else if (timeoutCnt > 0) { z += DESTROYED_Z / 60; --timeoutCnt; if (timeoutCnt <= 0) { remove(); return; } mtr = 0; } else { controlFireCnt(); mtr = 1; ++bossTimer; if (bossTimer > BOSS_TIMEOUT) { timeoutCnt = TIMEOUT_CNT; shield = 0; removeTopBullets(); } } manager->setBossShieldMeter (shield, battery[0].shield, battery[1].shield, battery[2].shield, battery[3].shield, mtr); } ++cnt; if (appCnt <= 0 && dstCnt <= 0 && timeoutCnt <= 0) checkDamage(); }