当前位置: 首页>>代码示例>>C++>>正文


C++ CItem::GetStrengthInc方法代码示例

本文整理汇总了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);
}
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:28,代码来源:Menu.cpp

示例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;
	}
}
开发者ID:88er,项目名称:tutorials,代码行数:41,代码来源:Player.cpp

示例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);
}
开发者ID:88er,项目名称:tutorials,代码行数:24,代码来源:ShopKeeper.cpp


注:本文中的CItem::GetStrengthInc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。