Пример #1
0
void Case::transmettreAttaque(int nbPV, Entite*e) {
    if (m_occupant!=NULL) {
        if(e->Getnom() == "Chevalier"
           || e->Getnom() == "Archer"
           || e->Getnom() == "Pretre"
           || e->Getnom() == "Magicien"
           || e->Getnom() == "Voleur"
           || e->Getnom() == "Guerrier")
           m_occupant->modifierVie(nbPV + ((Unite*)e)->getBonusUnite()[1]);
        else
        {
           m_occupant->modifierVie(nbPV);
        }

        if (!contientBatiment()&&isOccupee() &&getOccupant()->getVie()==0){
            QPixmap *tombe;
            tombe=new QPixmap("images/Coffin.png");
            (getOccupant())->setPixmap(tombe->copy(0,96,32,32));

            getOccupant()->setFlag(QGraphicsItem::ItemIsSelectable,false);
            setOccupant(NULL);
        }
        else if(isOccupee() && getOccupant()->Getnom()== "Chateau" && getOccupant()->getVie()==0)
        {
            QPixmap *tombe;
            tombe=new QPixmap("images/ChateauDetruit.png");
            (getOccupant())->setPixmap(tombe->copy(0,96,32,32));

            QMessageBox popup;
            popup.setText("Victoire " + this->getOccupant()->getJoueur()->getPseudo() + "!");
            popup.exec();

             this->getOccupant()->getPosition()[0]->parent()->finDuJeu();

        }
        else if(isOccupee() && getOccupant()->Getnom() == "Tour" && getOccupant()->getVie()==0)
        {
            QPixmap *tombe;
            tombe=new QPixmap("images/TourDetruite.png");
            (getOccupant())->setPixmap(tombe->copy(0,96,32,32));

            this->parent()->supprimerTour((Batiment*)this->getOccupant());
            getOccupant()->setFlag(QGraphicsItem::ItemIsSelectable,false);
            setOccupant(NULL);
        }

    }
}
Пример #2
0
void game_create_character_as_passenger(const ScriptArguments& args)
{
	auto vehicle = static_cast<VehicleObject*>(args.getObject<VehicleObject>(0));
	auto type = args[1].integerValue();
	RW_UNUSED(type);
	RW_UNIMPLEMENTED("game_create_character_as_passenger(): character type");
	auto id = args[2].integerValue();
	auto seat = args[3].integerValue();

	auto character = args.getWorld()->createPedestrian(id, vehicle->getPosition() + spawnMagic);
	new DefaultAIController(character);

	if (seat <= -1) {
		for (seat = 0; seat < static_cast<int>(vehicle->info->seats.size()); seat++) {
			if (vehicle->getOccupant(seat) == nullptr && !vehicle->isOccupantDriver(seat)) {
				break;
			}
		}
	} else {
		/// @todo 0 - passenger seat (or back seat of bike); 1 - left rear seat; 2 - right rear seat
		seat++;
	}

	RW_CHECK(seat < static_cast<int>(vehicle->info->seats.size()), "Seat index too high");
	RW_CHECK(vehicle->getOccupant(seat) == nullptr, "Seat is not free");
	RW_CHECK(vehicle->isOccupantDriver(seat) == false, "Seat is not a passenger seat");

	character->setCurrentVehicle(vehicle, seat);
	vehicle->setOccupant(seat, character);

	*args[4].globalInteger = character->getGameObjectID();
}
Пример #3
0
void game_create_character_in_vehicle(const ScriptArguments& args)
{
	auto vehicle = static_cast<VehicleObject*>(args.getObject<VehicleObject>(0));
	auto type = args[1].integer;
	RW_UNUSED(type);
	RW_UNIMPLEMENTED("game_create_character_in_vehicle(): character type");
	auto id = args[2].integer;
	
	auto character = args.getWorld()->createPedestrian(id, vehicle->getPosition() + spawnMagic);
	new DefaultAIController(character);
	
	character->setCurrentVehicle(vehicle, 0);
	vehicle->setOccupant(0, character);
	
	*args[3].globalInteger = character->getGameObjectID();
}