void Tile::updateCurrent(sf::Time dt, CommandQueue& commands) { // Entity has been destroyed: Possibly drop pickup, mark for removal if (isDestroyed()) { checkPickupDrop(commands); mExplosion.update(dt); // Play explosion sound only once if (!mExplosionBegan) { // Play sound effect SoundEffect::ID soundEffect = (randomInt(2) == 0) ? SoundEffect::Explosion1 : SoundEffect::Explosion2; playLocalSound(commands, soundEffect); // Emit network game action for explosions if (isBlock()) { sf::Vector2f position = getWorldPosition(); Command command; command.category = Category::Network; command.action = derivedAction<NetworkNode>([position] (NetworkNode& node, sf::Time) { node.notifyGameAction(GameActions::EnemyExplode, position); }); commands.push(command); mExplosionBegan = true; } } return; } Entity::updateCurrent(dt, commands); }
void WaveGenerator::updateCurrent(sf::Time dt, CommandQueue &commands) { mWaveTimer += dt; switch(mWaveState) { case WaitInitTime: { if(!mGaveTraps) { Command cmd; cmd.category = Category::Traplist; cmd.action = derivedAction<TraplistNode>([&](TraplistNode& traps, sf::Time dt) { if(mCurrentWaveIndex == 0) traps.generateTraps(5); else if(mCurrentWaveIndex == 1) traps.generateTraps(mWaves[mCurrentWaveIndex].nbTraps); else traps.grantTrap(mWaves[mCurrentWaveIndex].nbTraps); }); commands.push(cmd); // New Wave sound playLocalSound(commands, Sounds::NextWave); mGaveTraps = true; } if(mWaveTimer >= mWaves[mCurrentWaveIndex].initialWaitTime) { mWaveState = PopingAdds; mWaveTimer = sf::Time::Zero; if(mWaves[mCurrentWaveIndex].kidsToKill == 0) mWaveState = WaitingTheEnd; } } break; case PopingAdds: if(mWaveTimer >= mWaves[mCurrentWaveIndex].repopTime) { popKid(commands, mWaves[mCurrentWaveIndex].minIntel, mWaves[mCurrentWaveIndex].kidSpeed); mWaveTimer = sf::Time::Zero; if(mNbKidPoped >= mWaves[mCurrentWaveIndex].kidsToKill) { mWaveState = WaitingTheEnd; mWaveTimer = sf::Time::Zero; } } break; case WaitingTheEnd: if(mKidsRemaining == 0 || mWaveTimer >= mWaves[mCurrentWaveIndex].waveTotalTime) { nextWave(); } default:break; } }