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


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

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

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

示例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;
		}
	}
}
开发者ID:PurpleYouko,项目名称:Wibble_Wibble,代码行数:23,代码来源:CItemSlot.cpp


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