Exemplo n.º 1
0
Arquivo: map.cpp Projeto: Ra8/RAP
void Map::escapeFromGate(){
    bool escaped=false;
    for(unsigned int i =0; i<roads.size(); i++){
        if(roads[i]->type==2 && robber->collidesWithItem(roads[i],Qt::ContainsItemShape)){
            escaped= true;
        }
    }
    if(escaped){
        emit TOGGLEPAUSESIGNAL();
        QMessageBox msgBox;
        if(role==0){
            if(statsPanel->getCurrentMoney()>=targets[level]){
                msgBox.setText("You WON!\nYou succesfully escaped!!");
                increaseLevel();
            }
            else
                msgBox.setText("You LOST!\nYou have escaped without getting the target");
        } else {
            if(statsPanel->getCurrentMoney()>=targets[level])
                msgBox.setText("You LOST!\nThe robber escaped and got his target!!");
            else{
                msgBox.setText("You WON!\nThe robber escaped without getting his target");
                increaseLevel();
            }
        }
        msgBox.exec();
    }
}
Exemplo n.º 2
0
Arquivo: map.cpp Projeto: Ra8/RAP
void Map::tryToArrestRobber(){
    double minDis=100;

    for(unsigned int i=0;i<polices.size();i++){
        minDis=min(minDis,robber->distanceTo(polices[i]->pos()));
    }
    for(unsigned int i=0;i<guards.size();i++){
        if(guards[i]->canFollowRobber)
            minDis=min(minDis,robber->distanceTo(guards[i]->pos()));
    }
    if(minDis<20){
        emit TOGGLEPAUSESIGNAL();
        QMessageBox msgBox;
        if(role==0)
            msgBox.setText("You LOST!\nThe police caught you!!");
        else{
            msgBox.setText("You WON!\nYou caught the robber!!");
            increaseLevel();
        }
        msgBox.exec();
    }
}
Exemplo n.º 3
0
int Game::update(sf::Event* event)
{
	currentState = State::GAME;

	if (isGameOver)
	{
		score.updateHighScore();
		currentState =  State::GAME_OVER;
	}
	else
	{
		handleInput(event);

		solveCollisions();

		for (unsigned i = 0; i < missiles.size(); i++)
		{
			if (missiles[i]->getAlive())
			{
				missiles[i]->update(&explosions);
			}
			else
			{
				delete missiles[i];
				missiles.erase(missiles.begin() + i);
			}
		}
		for (unsigned i = 0; i < meteors.size(); i++)
		{
			if (meteors[i]->getAlive())
			{
				meteors[i]->update(&explosions);
			}
			else
			{
				if (meteors[i]->getIsWaveSpawner())
				{
					dropMeteorWave();
				}
				if (!meteors[i]->getReachedDestination())
				{
					score.offsetScore(settings->scoreForMeteor);
				}
				delete meteors[i];
				meteors.erase(meteors.begin() + i);
			}
		}
		for (unsigned i = 0; i < explosions.size(); i++)
		{
			if (explosions[i]->getAlive())
			{
				explosions[i]->update();
			}
			else
			{
				delete explosions[i];
				explosions.erase(explosions.begin() + i);
			}
		}

		if (nrOfMeteorsLeftTilNextLevel <= 0 && meteors.empty())
		{
			if (currentLevel != 0)
			{
				setRandomBackgroundColor();
			}
			increaseLevel();
			dropMeteorWave();
		}
	}

	return currentState;
}