本文整理汇总了C++中CItem::GetStrengthInc方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetStrengthInc方法的具体用法?C++ CItem::GetStrengthInc怎么用?C++ CItem::GetStrengthInc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetStrengthInc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawStatsString
void DrawStatsString()
{
// Let's get the current selected item from the user
CItem *pItem = g_Menu.GetSelectedItem();
char szStats[kStatsMenuWidth] = {0};
// If there is an item that is selected, let's display its stats
if(pItem)
{
sprintf(szStats, "LifeInc: %d strengthInc: %d ProtectionInc: %d",
pItem->GetLifeInc(), pItem->GetStrengthInc(), pItem->GetProtectionInc());
}
else // Otherwise display blank stats
{
sprintf(szStats, "LifeInc: strengthInc: ProtectionInc: ");
}
// Draw the stats in the correct menu box at the bottom
g_Menu.DrawString(szStats, (int)strlen(szStats), kStatsMenuX + kTileWidth,
kStatsMenuY + kTileHeight-3, NULL);
// Now let's display the current player's stats. Let's create the string
sprintf(szStats, "Hp: %d Str: %d Ptc: %d",
g_Player.GetHealth(), g_Player.GetStrength(), g_Player.GetProtection());
// Draw the player's stats in the top left of the inventory menu
g_Menu.DrawString(szStats, (int)strlen(szStats), kPlrStatsMenuX, kPlrStatsMenuY, NULL);
}
示例2: SetEquipment
void CPlayer::SetEquipment(CItem *pItem, int type)
{
// Return if there is no valid item
if(!pItem) return;
// We need to store the previous item to minus it's stats from the player
CItem *pLastItem = NULL;
// Check the type desired to change and store a pointer to it for stats reasons
switch (type)
{
case kHead: pLastItem = m_pHead; break;
case kChest: pLastItem = m_pChest; break;
case kWeapon: pLastItem = m_pWeapon; break;
case kFeet: pLastItem = m_pFeet; break;
default: pLastItem = m_pHead; break;
}
// If there was an item equipped, let's take back it's stats before we add new ones
if(pLastItem)
{
m_healthMax -= pItem->GetLifeInc();
// When we take away the max health stat we need to make sure our health is below it
if(m_health > m_healthMax)
m_health = m_healthMax;
m_strength -= pLastItem->GetStrengthInc();
m_protection -= pLastItem->GetProtectionInc();
}
// Depending on the type, let's store a pointer to the new item
switch (type)
{
case kHead: m_pHead = pItem; break;
case kChest: m_pChest = pItem; break;
case kWeapon: m_pWeapon = pItem; break;
case kFeet: m_pFeet = pItem; break;
default: m_pHead = pItem; break;
}
}
示例3: DrawItemStats
void DrawItemStats()
{
// Get the selected item to draw it's stats
CItem *pItem = g_Shop.GetSelectedItem();
char szStats[kStatsMenuWidth] = {0};
// If there is an item selected, display it's stats at the bottom of the menu
if(pItem)
{
sprintf(szStats, "LifeInc: %d strengthInc: %d ProtectionInc: %d",
pItem->GetLifeInc(), pItem->GetStrengthInc(), pItem->GetProtectionInc());
}
else
{
sprintf(szStats, "LifeInc: strengthInc: ProtectionInc: ");
}
// Draw the stats string to the bottom menu dialog box
g_Shop.DrawString(szStats, (int)strlen(szStats), kStatsMenuX + 3, kStatsMenuY + 2, NULL);
// Display the players gold in the left dialog box
sprintf(szStats, "$$$: %d", g_Player.GetGold());
g_Shop.DrawString(szStats, (int)strlen(szStats), kPlrStatsMenuX, kPlrStatsMenuY, NULL);
}