Ejemplo n.º 1
0
void QtTDContext::resetMap() {
        removeAllEnemies();
        clearTowers();
        setCredits(creditsStart);
        setInterest(interestStart, interestIncrease);
        resetLives(livesStart);
        resetBonus();
        resetScore();
        resetWaves();
        gameTime = 0;
        //mainApp.resetMap();
}
Ejemplo n.º 2
0
    bool tick(){
        for(unsigned int i=0; i<velocity; i++){ // TODO: Put here new enemies with RoundsManager
            auto it1 = enemies.begin();
            while(it1 != enemies.end()){
                bool lost = life<=0;
                Enemy* e = *it1;
                if(e->tick()){
                    life -= e->getDamage();
                    delete e;
                    it1 = enemies.erase(it1);
                }else it1++;

                if(life<=0 && !lost){
                    money = 0;
                    clearEntities();

                    for(Tower* t:towers){
                        entities.push_back(new ExplosionEntity(getRealPosition(t->getPosition()), pixelsPerSquare, 200));
                    }

                    clearTowers();
                }
            }
            auto it2 = entities.begin();
            while(it2 != entities.end()){
                Entity* e = *it2;
                if(e->tick()){
                    delete e;
                    it2 = entities.erase(it2);
                }else it2++;
            }
            for(Tower* t : towers){
                t->tick();
            }

            if(life>0){
                if(tickCount%400 == 1)
                    enemies.push_back(new InhibitorEnemy(1.0, 30+tickCount/500, 1));
                else if(tickCount%20 == 1)
                    enemies.push_back(new BasicEnemy(1.0 + (double)(rand()%10)/10.0, 15+tickCount/500, 1));
            }
            ++tickCount;
        }

        return false;
    }