本文整理汇总了C++中Armor::getSubtype方法的典型用法代码示例。如果您正苦于以下问题:C++ Armor::getSubtype方法的具体用法?C++ Armor::getSubtype怎么用?C++ Armor::getSubtype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armor
的用法示例。
在下文中一共展示了Armor::getSubtype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeEquipment
void BattleCharacterEquipment::removeEquipment(EquipmentPiece *equipment) {
switch (equipment->getType()) {
case EquipmentPiece::WEAPON:
{
Weapon *weapon = dynamic_cast<Weapon*>(equipment);
switch (weapon->getSubtype()) {
case Weapon::MAINHAND:
setMainhand(0);
break;
case Weapon::OFFHAND:
setOffhand(0);
break;
case Weapon::TWOHANDED:
setTwohanded(0);
break;
}
}
break;
case EquipmentPiece::ARMOR:
{
Armor *armor = dynamic_cast<Armor*>(equipment);
switch (armor->getSubtype()) {
case Armor::HELMET:
setHelmet(0);
break;
case Armor::TORSO:
setTorso(0);
break;
case Armor::LEGGINGS:
setLeggings(0);
break;
case Armor::GLOVES:
setGloves(0);
break;
case Armor::BOOTS:
setBoots(0);
break;
}
}
break;
case EquipmentPiece::ACCESSORY:
{
Accessory *accessory = dynamic_cast<Accessory*>(equipment);
switch (accessory->getSubtype()) {
case Accessory::EARRING:
setEarring(0);
break;
case Accessory::NECKLACE:
setNecklace(0);
break;
case Accessory::RING:
setRing(0);
break;
}
}
break;
}
}
示例2: equipmentFilter
bool MenuEquipmentScreen::equipmentFilter(EquipmentPiece *equipment) {
// Filter by type (Weapon, Armor or Accessory)
EquipmentPiece::Type typeFilter;
if (_equippedEquipmentItems.indexOf(_currentEquippedEquipmentItem) < 2)
typeFilter = EquipmentPiece::WEAPON;
else if (_equippedEquipmentItems.indexOf(_currentEquippedEquipmentItem) < 7)
typeFilter = EquipmentPiece::ARMOR;
else
typeFilter = EquipmentPiece::ACCESSORY;
if (equipment->getType() != typeFilter)
return false;
// Filter by subtype
if (typeFilter == EquipmentPiece::WEAPON) {
Weapon *weapon = dynamic_cast<Weapon*>(equipment);
int subTypeFilter = _equippedEquipmentItems.indexOf(_currentEquippedEquipmentItem);
if ((weapon->getSubtype() != Weapon::TWOHANDED) && (subTypeFilter != weapon->getSubtype()))
return false;
} else if (typeFilter == EquipmentPiece::ARMOR) {
Armor *armor = dynamic_cast<Armor*>(equipment);
int subTypeFilter = _equippedEquipmentItems.indexOf(_currentEquippedEquipmentItem);
if (subTypeFilter != armor->getSubtype())
return false;
} else if (typeFilter == EquipmentPiece::ACCESSORY) {
Accessory *accessory = dynamic_cast<Accessory*>(equipment);
int subTypeFilter = _equippedEquipmentItems.indexOf(_currentEquippedEquipmentItem);
if (subTypeFilter != accessory->getSubtype())
return false;
}
QVector<QPair<Class*, int>> classes = equipment->getClasses();
for (int i = 0; i < classes.size(); i++) {
QPair<Class*, int> it = classes.at(i);
if ((it.first == _character->getClass()) && (it.second <= _character->getLevel()))
return true;
}
return false;
}