本文整理汇总了C++中PhysicalObject::getOnItemCollisionFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicalObject::getOnItemCollisionFunction方法的具体用法?C++ PhysicalObject::getOnItemCollisionFunction怎么用?C++ PhysicalObject::getOnItemCollisionFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicalObject
的用法示例。
在下文中一共展示了PhysicalObject::getOnItemCollisionFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
new RescueAnimation(kart);
}
else if (anim->isExplodeKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
ExplosionAnimation::create(kart);
}
else if (anim->isFlattenKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
const KartProperties* kp = kart->getKartProperties();
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
}
continue;
}
// now the first object must be a projectile
// =========================================
if(p->getUserPointer(1)->is(UserPointer::UP_TRACK))
{
// Projectile hits track
// ---------------------
p->getUserPointer(0)->getPointerFlyable()->hitTrack();
}
else if(p->getUserPointer(1)->is(UserPointer::UP_PHYSICAL_OBJECT))
{
// Projectile hits physical object
// -------------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Flyable* flyable = p->getUserPointer(0)->getPointerFlyable();
PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject();
std::string obj_id = obj->getID();
std::string scripting_function = obj->getOnItemCollisionFunction();
if (scripting_function.size() > 0)
{
script_engine->runFunction("void " + scripting_function + "(int, int, const string)",
[&](asIScriptContext* ctx) {
ctx->SetArgDWord(0, (int)flyable->getType());
ctx->SetArgDWord(1, flyable->getOwnerId());
ctx->SetArgObject(2, &obj_id);
});
}
flyable->hit(NULL, obj);
if (obj->isSoccerBall() &&
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setLastKartTohitBall(kartId);
}
}
else if(p->getUserPointer(1)->is(UserPointer::UP_KART))
{
// Projectile hits kart
// --------------------
// Only explode a bowling ball if the target is
// not invulnerable
AbstractKart* target_kart = p->getUserPointer(1)->getPointerKart();
PowerupManager::PowerupType type = p->getUserPointer(0)->getPointerFlyable()->getType();
if(type != PowerupManager::POWERUP_BOWLING || !target_kart->isInvulnerable())
{
Flyable *f = p->getUserPointer(0)->getPointerFlyable();
f->hit(target_kart);
示例2: update
//.........这里部分代码省略.........
else if (anim->isFlattenKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
const KartProperties *kp = kart->getKartProperties();
// Count squash only once from original state
bool was_squashed = kart->isSquashed();
if (kart->setSquash(kp->getSwatterSquashDuration(),
kp->getSwatterSquashSlowdown()) && !was_squashed)
{
World::getWorld()->kartHit(kart->getWorldKartId());
}
}
continue;
}
// now the first object must be a projectile
// =========================================
if(p->getUserPointer(1)->is(UserPointer::UP_TRACK))
{
// Projectile hits track
// ---------------------
p->getUserPointer(0)->getPointerFlyable()->hitTrack();
}
else if(p->getUserPointer(1)->is(UserPointer::UP_PHYSICAL_OBJECT))
{
// Projectile hits physical object
// -------------------------------
Scripting::ScriptEngine* script_engine = Scripting::ScriptEngine::getInstance();
Flyable* flyable = p->getUserPointer(0)->getPointerFlyable();
PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject();
std::string obj_id = obj->getID();
std::string scripting_function = obj->getOnItemCollisionFunction();
if (scripting_function.size() > 0)
{
script_engine->runFunction(true, "void " + scripting_function + "(int, int, const string)",
[&](asIScriptContext* ctx) {
ctx->SetArgDWord(0, (int)flyable->getType());
ctx->SetArgDWord(1, flyable->getOwnerId());
ctx->SetArgObject(2, &obj_id);
});
}
flyable->hit(NULL, obj);
if (obj->isSoccerBall() &&
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setBallHitter(kartId);
}
}
else if(p->getUserPointer(1)->is(UserPointer::UP_KART))
{
// Projectile hits kart
// --------------------
// Only explode a bowling ball if the target is
// not invulnerable
AbstractKart* target_kart = p->getUserPointer(1)->getPointerKart();
PowerupManager::PowerupType type = p->getUserPointer(0)->getPointerFlyable()->getType();
if(type != PowerupManager::POWERUP_BOWLING || !target_kart->isInvulnerable())
{
Flyable *f = p->getUserPointer(0)->getPointerFlyable();
f->hit(target_kart);