本文整理汇总了C++中AbstractKart::getAttachment方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractKart::getAttachment方法的具体用法?C++ AbstractKart::getAttachment怎么用?C++ AbstractKart::getAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractKart
的用法示例。
在下文中一共展示了AbstractKart::getAttachment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAttachment
// ----------------------------------------------------------------------------
void addAttachment(Attachment::AttachmentType type)
{
World* world = World::getWorld();
if (world == NULL) return;
for (unsigned int i = 0; i < world->getNumKarts(); i++)
{
AbstractKart *kart = world->getKart(i);
if (!kart->getController()->isLocalPlayerController())
continue;
if (type == Attachment::ATTACH_ANVIL)
{
kart->getAttachment()
->set(type, kart->getKartProperties()->getAnvilDuration());
kart->adjustSpeed(kart->getKartProperties()->getAnvilSpeedFactor());
kart->updateWeight();
}
else if (type == Attachment::ATTACH_PARACHUTE)
{
kart->getAttachment()
->set(type, kart->getKartProperties()->getParachuteDuration());
}
else if (type == Attachment::ATTACH_BOMB)
{
kart->getAttachment()
->set(type, stk_config->m_bomb_time);
}
}
} // addAttachment
示例2: addAttachment
void addAttachment(Attachment::AttachmentType type)
{
World* world = World::getWorld();
if (world == NULL) return;
for(unsigned int i = 0; i < world->getNumKarts(); i++)
{
AbstractKart *kart = world->getKart(i);
if (kart->getController()->isPlayerController()) {
if (type == Attachment::ATTACH_ANVIL)
{
kart->getAttachment()
->set(type, stk_config->m_anvil_time);
kart->adjustSpeed(stk_config->m_anvil_speed_factor);
kart->updateWeight();
}
else if (type == Attachment::ATTACH_PARACHUTE)
{
kart->getAttachment()
->set(type, stk_config->m_parachute_time);
}
else if (type == Attachment::ATTACH_BOMB)
{
kart->getAttachment()
->set(type, stk_config->m_bomb_time);
}
}
}
}
示例3: squashThingsAround
/** Squash karts or items that are around the end position (determined using
* a joint) of the swatter.
*/
void Swatter::squashThingsAround()
{
const KartProperties* kp = m_kart->getKartProperties();
// Square of the minimum distance
float min_dist2 = kp->getSwatterDistance2();
const World* world = World::getWorld();
// Get the node corresponding to the joint at the center of the swatter
// (by swatter, I mean the thing hold in the hand, not the whole thing)
scene::ISceneNode* swatter_node = m_scene_node->getJointNode("Swatter");
assert(swatter_node);
Vec3 swatter_pos = swatter_node->getAbsolutePosition();
m_swat_sound->setPosition(swatter_pos);
m_swat_sound->play();
// Squash karts around
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
AbstractKart *kart = world->getKart(i);
// TODO: isSwatterReady()
if(kart->isEliminated() || kart==m_kart)
continue;
// don't swat an already hurt kart
if (kart->isInvulnerable() || kart->isSquashed())
continue;
float dist2 = (kart->getXYZ()-swatter_pos).length2();
if(dist2 >= min_dist2) continue; // too far away, ignore this kart
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
if (kart->getAttachment()->getType()==Attachment::ATTACH_BOMB)
{ // make bomb explode
kart->getAttachment()->update(10000);
HitEffect *he = new Explosion(m_kart->getXYZ(), "explosion", "explosion.xml");
if(m_kart->getController()->isPlayerController())
he->setPlayerKartHit();
projectile_manager->addHitEffect(he);
ExplosionAnimation::create(kart);
} // if kart has bomb attached
World::getWorld()->kartHit(kart->getWorldKartId());
} // for i < num_kartrs
// TODO: squash items
} // squashThingsAround
示例4: drawGlobalPlayerIcons
//.........这里部分代码省略.........
NULL, NULL, true);
}
//draw status info - icon fade out in case of rescue/explode
if (icon && dynamic_cast<RescueAnimation*>(kart->getKartAnimation()))
{
//icon fades to the left
float t = kart->getKartAnimation()->getAnimationTimer();
float t_anim=100*sin(0.5f*M_PI*t);
const core::rect<s32> rect1(core::position2d<s32>(0,0),
icon->getOriginalSize());
const core::rect<s32> pos1((int)(x-t_anim), y,
(int)(x+w-t_anim), y+w);
draw2DImage(icon, pos1, rect1,
NULL, NULL, true);
}
if (icon && !kart->getKartAnimation() && kart->isSquashed() )
{
//syncs icon squash with kart squash
const core::rect<s32> destRect(core::position2d<s32>(x,y+w/4),
core::position2d<s32>(x+w,y+w*3/4));
const core::rect<s32> sourceRect(core::position2d<s32>(0,0),
icon->getOriginalSize());
draw2DImage(icon, destRect,
sourceRect, NULL, NULL,
true);
}
if (icon &&
dynamic_cast<ExplosionAnimation*>(kart->getKartAnimation()) )
{
//exploses into 4 parts
float t = kart->getKartAnimation()->getAnimationTimer();
float t_anim=50.0f*sin(0.5f*M_PI*t);
u16 icon_size_x=icon->getOriginalSize().Width;
u16 icon_size_y=icon->getOriginalSize().Height;
const core::rect<s32> rect1(0, 0, icon_size_x/2,icon_size_y/2);
const core::rect<s32> pos1((int)(x-t_anim), (int)(y-t_anim),
(int)(x+w/2-t_anim),
(int)(y+w/2-t_anim));
draw2DImage(icon, pos1, rect1,
NULL, NULL, true);
const core::rect<s32> rect2(icon_size_x/2,0,
icon_size_x,icon_size_y/2);
const core::rect<s32> pos2((int)(x+w/2+t_anim),
(int)(y-t_anim),
(int)(x+w+t_anim),
(int)(y+w/2-t_anim));
draw2DImage(icon, pos2, rect2,
NULL, NULL, true);
const core::rect<s32> rect3(0, icon_size_y/2, icon_size_x/2,icon_size_y);
const core::rect<s32> pos3((int)(x-t_anim), (int)(y+w/2+t_anim),
(int)(x+w/2-t_anim), (int)(y+w+t_anim));
draw2DImage(icon, pos3, rect3, NULL, NULL, true);
const core::rect<s32> rect4(icon_size_x/2,icon_size_y/2,icon_size_x,icon_size_y);
const core::rect<s32> pos4((int)(x+w/2+t_anim), (int)(y+w/2+t_anim),
(int)(x+w+t_anim), (int)(y+w+t_anim));
draw2DImage(icon, pos4, rect4, NULL, NULL, true);
}
//Plunger
if (kart->getBlockedByPlungerTime()>0)
{
video::ITexture *icon_plunger =
powerup_manager->getIcon(PowerupManager::POWERUP_PLUNGER)->getTexture();
if (icon_plunger != NULL)
{
const core::rect<s32> rect(core::position2d<s32>(0,0),
icon_plunger->getOriginalSize());
const core::rect<s32> pos1(x+10, y-10, x+w+10, y+w-10);
draw2DImage(icon_plunger, pos1,
rect, NULL, NULL,
true);
}
}
//attachment
if (kart->getAttachment()->getType() != Attachment::ATTACH_NOTHING)
{
video::ITexture *icon_attachment =
attachment_manager->getIcon(kart->getAttachment()->getType())
->getTexture();
if (icon_attachment != NULL)
{
const core::rect<s32> rect(core::position2d<s32>(0,0),
icon_attachment->getOriginalSize());
const core::rect<s32> pos1(x-20, y-10, x+w-20, y+w-10);
draw2DImage(icon_attachment,
pos1, rect, NULL,
NULL, true);
}
}
} //next position
} // drawGlobalPlayerIcons