本文整理汇总了C++中Weapon::fire方法的典型用法代码示例。如果您正苦于以下问题:C++ Weapon::fire方法的具体用法?C++ Weapon::fire怎么用?C++ Weapon::fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::fire方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attack
//------------------------------------------------------------------------------
void Actor::attack()
{
Weapon w = getWeapon();
if( w.canFire() )
{
Projectile* p = w.fire( getAimingDirection() );
p->setPosition( getPosition() );
mpEngine->addProjectile( p );
setWeapon( w );
}
}
示例2: fire
void Ship::fire(int weaponIndex)
{
if (weaponIndex >= 0 && weaponIndex < (int)weapons_.size())
{
transform_->getMatrix(weaponTransformation_, false);
//keeping weapon's local direction
Weapon* weapon = weapons_[weaponIndex].first;
weapon->currentDirection = weapon->direction;
weapon->currentDirection.rotateVector(weaponTransformation_);
//keeping weapon's local position
Vector3 weaponPos = weapons_[weaponIndex].second;
weaponPos.rotateVector(weaponTransformation_);
weapon->position = transform_->getPosition() + weaponPos;
weapon->fire();
}
else
Logger::PrintWarning("Ship::fire - invalid argument\n");
}
示例3: fireWeaponGroup
//---------------------------------------------------------------------------
void Avatar::fireWeaponGroup(int /*groupId*/)
{
// for now, fire everything
ComponentList list;
findComponents(EquipmentSlotComponent::getClassDef(), list);
for (ComponentList::iterator it = list.begin(); it != list.end(); ++it)
{
EquipmentSlotComponent* pSlot = static_cast<EquipmentSlotComponent*>(*it);
if (pSlot)
{
size_t numEquipment = pSlot->getNumEquipment();
for (size_t i=0; i<numEquipment; ++i)
{
Mountable* pMountable = pSlot->getEquipment(i);
if (pMountable && pMountable->isOfType(Weapon::getClassDef()))
{
Weapon* pWeapon = static_cast<Weapon*>(pMountable);
pWeapon->fire();
}
}
}
}
}
示例4: CheckForInput
////////////////////////////////////////////////////////////
///Entrypoint of application
////////////////////////////////////////////////////////////
void CheckForInput(float &x, float &y, bool & isSpace, bool &isLeft, bool &isRight, bool &isUp, bool &isDown, bool &isSwitch, Weapon& myWeapon)
{
//simple input used for testing
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && !isSpace)
{
isSpace = true;
myWeapon.fire(Vector2D(x, y), Vector2D(400, 300));
}
else
{
isSpace = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) && !isLeft)
{
isLeft = true;
x -= 5;
}
else
{
isLeft = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && !isRight)
{
isRight = true;
x += 5;
}
else
{
isRight = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && !isUp)
{
isUp = true;
y += 5;
}
else
{
isUp = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) && !isDown)
{
isDown = true;
y -= 5;
}
else
{
isDown = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) && !isSwitch)
{
isSwitch = true;
myWeapon.switchWeapon();
cout << "Switched weapon" << endl;
}
else
{
isSwitch = false;
}
cout << "XDir: " << x << endl;
cout << "YDir: " << y << endl;
}