void WaveController::update(sf::Time const& elapsedTime) {
	mTimeSinceWave += elapsedTime.asSeconds();

	if (!mWaveQueue.empty() && isTimeToSpawnWave()) {
		spawnWave();
	}
}
Exemple #2
0
/**
 * Handles collisions between objects and removes them if they have zero mass
 */
void System::collideAndClean()
{
    for(auto &proj : projectiles) {
        Collide(playerShip, proj);
        for (auto &ship: ships) {
            Collide(ship, proj);
        }
    }
    for(auto &proj : AIprojectiles) {
        Collide(playerShip, proj);
    }

    cleanProjectiles(AIprojectiles);
    cleanProjectiles(projectiles);

    //Damages ships that are out of bounds and deletes those that have died
    auto shipEnd = std::remove_if(ships.begin(),    ships.end(),  [this](Ship &B){
                if(B.getPosition().x * B.getPosition().x + B.getPosition().y * B.getPosition().y
                   > this->killRadius * this->killRadius)
                    B.Damage(1);
            return B.getMass() == 0.0;});
    if(playerShip.getPosition().x * playerShip.getPosition().x + playerShip.getPosition().y * playerShip.getPosition().y
                   > this->killRadius * this->killRadius)
                    playerShip.Damage(1);
    for(auto shipIter = shipEnd; shipIter < ships.end();shipIter++)
    {
        crates.emplace_back(shipIter->getPosition(), shipIter->getWeaponCopy());

    }
    ships.erase(shipEnd  ,  ships.end());
    if(ships.size() == 0)
        spawnWave();

    for(auto &crate : crates)
    {
        CollectCrates(playerShip,crate);
        for(auto &ship: ships)
        {
            CollectCrates(ship,crate);
        }
    }

     auto crateEnd = std::remove_if(crates.begin(),    crates.end(),  [this](const Crate &B){
            return B.getMass() == 0.0;});
    crates.erase(crateEnd    ,        crates.end());



}
Exemple #3
0
System::System() : playerShip(Tuple(0,0)) {
    spawnWave();
}