本文整理汇总了C++中CItem::GetIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetIndex方法的具体用法?C++ CItem::GetIndex怎么用?C++ CItem::GetIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckForItem
void CMap::CheckForItem(int x, int y)
{
// Go through all of the items to check if we have a match
for(int i = 0; i < (int)m_vItems.size(); i++)
{
CItem *pItem = &m_vItems[i];
// Check if the player position is the same as the current item
if(x == pItem->GetIndex().X && y == pItem->GetIndex().Y)
{
// Create a new item and then copy the current item's data to the new item
CItem newItem;
memcpy(&newItem, pItem, sizeof(CItem));
// Check if this item has a special key with it
g_ActionKeys.HandleKey(pItem->GetActionKey());
// If our inventory isn't full, let's add it, otherwise do nothing
if(g_Player.GetInventorySize() < kMaxItems)
{
// Let's add the new item and then delete it from the map
g_Player.AddItem(newItem);
m_vItems.erase(m_vItems.begin() + i);
}
return;
}
}
}
示例2: ItemPromptSell
void ItemPromptSell()
{
// If the player finally decides to sell their item, this function is called.
// First we get the item and then calculate it's USED price (false).
CItem *pItem = g_Shop.GetSelectedItem();
int salePrice = CalculateItemPrice(pItem, false);
// Drop the item and delete it from the map to get rid of it from the player
g_Player.DropItem(pItem);
g_Map.DeleteTile(kItemType, pItem->GetIndex().X, pItem->GetIndex().Y);
// Add the money made to our current gold
g_Player.SetGold(g_Player.GetGold() + salePrice);
// Display the transaction made
char szMessage[80] = {0};
sprintf(szMessage, "You recieved %d gold for the %s.", salePrice, pItem->GetItemName());
g_Shop.DrawMessageBox(szMessage);
Sleep(1000);
}
示例3: Clear
void CItemSlot::Clear()
{
std::vector< CItem* >::iterator iter;
CItem* pItem = NULL;
for( iter = m_listItems.begin(); iter != m_listItems.end(); ++iter )
{
pItem = *iter;
if( pItem )
{
pItem->Clear();
m_pEvent->SetID( CTEventItem::EID_DEL_ITEM );
m_pEvent->SetIndex( pItem->GetIndex() );
m_pEvent->SetItem( pItem );
SetChanged();
NotifyObservers( m_pEvent );
delete pItem;
*iter = NULL;
}
}
}