Beispiel #1
0
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);
}
Beispiel #2
0
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;
	}
}
Beispiel #3
0
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);
}