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


C++ InventoryItem类代码示例

本文整理汇总了C++中InventoryItem的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItem类的具体用法?C++ InventoryItem怎么用?C++ InventoryItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InventoryItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onHandDragStop

void InventoryItem::onHandDragStop(Event::Mouse* event, HAND hand)
{
    // Check if mouse is over this item
    if (!Rect::inRect(event->position(), position(), size()))
    {
        return;
    }

    if (ItemsList* itemsList = dynamic_cast<ItemsList*>(event->target()))
    {
        InventoryItem* itemUi = itemsList->draggedItem();
        auto item = itemUi->item();
        itemsList->removeItem(itemUi, 1);
        // place current weapon back to inventory
        if (_item)
        {
            itemsList->addItem(this, 1);
        }
        this->setItem(item);
        auto player = Game::getInstance()->player();
        if (hand == HAND::LEFT)
        {
            player->setLeftHandSlot(item);
        }
        else
        {
            player->setRightHandSlot(item);
        }
    }
}
开发者ID:bugskiller,项目名称:falltergeist,代码行数:30,代码来源:InventoryItem.cpp

示例2: onArmorDragStop

void InventoryItem::onArmorDragStop(Event::Mouse* event)
{
    // Check if mouse is over this item
    if (!Rect::inRect(event->position(), position(), size()))
    {
        return;
    }

    if (ItemsList* itemsList = dynamic_cast<ItemsList*>(event->target()))
    {
        InventoryItem* draggedItem = itemsList->draggedItem();
        auto itemObject = draggedItem->item();
        if(itemObject->subtype() != Game::ItemObject::Subtype::ARMOR) return;
        itemsList->removeItem(draggedItem, 1);
        // place current armor back to inventory
        if (_item)
        {
            itemsList->addItem(this, 1);
        }
        this->setItem(itemObject);
        if (auto armor = dynamic_cast<Game::ArmorItemObject*>(itemObject))
        {
            Game::getInstance()->player()->setArmorSlot(armor);
        }
    }
}
开发者ID:dithillobothrium,项目名称:falltergeist,代码行数:26,代码来源:InventoryItem.cpp

示例3: fireCondition

bool AICurrentItemCondition::fireCondition() {
	InventoryItem *item = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();

	if (_item == kNoItemID)
		return item == 0;

	return item != 0 && item->getObjectID() == _item;
}
开发者ID:86400,项目名称:scummvm,代码行数:8,代码来源:ai_condition.cpp

示例4: showValues

/********************************************************
 *                       showValues                     *
 * This function displays the member data stored in the *
 * InventoryItem object passed to it by value.          *
 ********************************************************/
void showValues(InventoryItem item)
{
	cout << fixed << showpoint << setprecision(2) << endl;;
	cout << "Part Number  : "  << item.getPartNum() << endl;
	cout << "Description  : "  << item.getDescription() << endl;
	cout << "Units On Hand: "  << item.getOnHand() << endl;
	cout << "Price        : $" << item.getPrice() << endl;
}
开发者ID:jasoncearley,项目名称:CS162,代码行数:13,代码来源:pr7-09.cpp

示例5: clickActiveObject

void Client::clickActiveObject(u8 button, u16 id, u16 item_i)
{
	if(connectedAndInitialized() == false){
		infostream<<"Client::clickActiveObject() "
				"cancelled (not connected)"
				<<std::endl;
		return;
	}

	Player *player = m_env.getLocalPlayer();
	if(player == NULL)
		return;

	ClientActiveObject *obj = m_env.getActiveObject(id);
	if(obj){
		if(button == 0){
			ToolItem *titem = NULL;
			std::string toolname = "";

			InventoryList *mlist = player->inventory.getList("main");
			if(mlist != NULL)
			{
				InventoryItem *item = mlist->getItem(item_i);
				if(item && (std::string)item->getName() == "ToolItem")
				{
					titem = (ToolItem*)item;
					toolname = titem->getToolName();
				}
			}

			v3f playerpos = player->getPosition();
			v3f objpos = obj->getPosition();
			v3f dir = (objpos - playerpos).normalize();

			bool disable_send = obj->directReportPunch(toolname, dir);

			if(disable_send)
				return;
		}
	}

	/*
		length: 7
		[0] u16 command
		[2] u8 button (0=left, 1=right)
		[3] u16 id
		[5] u16 item
	*/
	u8 datasize = 2 + 1 + 6 + 2 + 2;
	SharedBuffer<u8> data(datasize);
	writeU16(&data[0], TOSERVER_CLICK_ACTIVEOBJECT);
	writeU8(&data[2], button);
	writeU16(&data[3], id);
	writeU16(&data[5], item_i);
	Send(0, data, true);
}
开发者ID:ray8888,项目名称:MINETEST-Minetest-classic-remoboray,代码行数:56,代码来源:client.cpp

示例6: getParentIndex

//----------------------------------------------------------------------------//
void InventoryModel::updateItemName(const ModelIndex& index, const String& newName)
{
    ModelIndex parent_index = getParentIndex(index);

    notifyChildrenDataWillChange(parent_index, 0, 1);

    InventoryItem* item = static_cast<InventoryItem*>(index.d_modelData);
    item->setText(newName);

    notifyChildrenDataChanged(parent_index, 0, 1);
}
开发者ID:OpenTechEngine-Libraries,项目名称:CEGUI,代码行数:12,代码来源:InventoryModel.cpp

示例7: removeItem

//------------------------------------------------------------------------------//
void InventoryReceiver::removeItem(InventoryItem& item)
{
    if (item.getParent() != this ||
        item.locationOnReceiverX() == -1 ||
        item.locationOnReceiverY() == -1)
            return;

    eraseItemFromContentMap(item);
    item.setLocationOnReceiver(-1, -1);
    removeChild(&item);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:12,代码来源:InventoryReceiver.cpp

示例8: createInventoryItem

video::ITexture * ItemObject::getItemImage()
{
	/*
		Create an inventory item to see what is its image
	*/
	video::ITexture *texture = NULL;
	InventoryItem *item = createInventoryItem();
	if(item)
		texture = item->getImage();
	if(item)
		delete item;
	return texture;
}
开发者ID:DMV27,项目名称:minetest,代码行数:13,代码来源:mapblockobject.cpp

示例9: restoreItemInBackpack

 void restoreItemInBackpack( Item* item,
                             int inventoryPosX,
                             int inventoryPosY,
                             size_t stackSize )
 {
   InventoryItem* invItem = new InventoryItem( item,
                                               inventoryPosX,
                                               inventoryPosY,
                                               Globals::getPlayer() );
   invItem->setCurrentStackSize( stackSize );
   Globals::getPlayer()->getInventory()->insertItemWithExchangeAt( invItem,
                                                                   inventoryPosX,
                                                                   inventoryPosY );
 }
开发者ID:kerlw,项目名称:Dawn,代码行数:14,代码来源:inventory.cpp

示例10: getLookNFeel

//------------------------------------------------------------------------------//
void InventoryItemRenderer::render()
{
    const WidgetLookFeel& wlf = getLookNFeel();

    InventoryItem* item = dynamic_cast<InventoryItem*>(d_window);

    if (!item)
        // render basic imagery
        wlf.getStateImagery(d_window->isDisabled() ? "Disabled" : "Enabled").render(*d_window);

    if (item->isBeingDragged())
        wlf.getStateImagery(item->currentDropTargetIsValid() ? "DraggingValidTarget" : "DraggingInvalidTarget").render(*item);
    else
        wlf.getStateImagery("Normal").render(*item);
}
开发者ID:CharlesSadler,项目名称:CharlesSadlerRTSGame,代码行数:16,代码来源:InventoryItemRenderer.cpp

示例11: EquipCharacter

	void GenericPlayerCharacter::EquipCharacter(int choosenObject)
	{
		for(Vector<InventoryItem*>::iterator playerObject = playerInventory.begin(); playerObject < playerInventory.end(); playerObject++)
		{
			InventoryItem* currentItem = *playerObject;
			if(currentItem->getObjectWorldID() == choosenObject)
			{
				playerAttackPoints = playerAttackPoints - currentEquipedObject->getAttackBoost();
				playerDefencePoints = playerDefencePoints - currentEquipedObject->getDefenceBoost();
				playerAttackPoints = playerAttackPoints - currentItem->getAttackBoost();
				playerDefencePoints = playerDefencePoints - currentItem->getDefenceBoost();
				break;
			}
		}
	}
开发者ID:viveksjoseph,项目名称:OpenXI,代码行数:15,代码来源:GenericPlayerCharacter.cpp

示例12: AddLootItem

InventoryItem* Item::AddLootItem(InventoryItem* pItem, int slotX, int slotY)
{
	if(pItem != NULL)
	{
		InventoryItem* pAddedLootItem = AddLootItem(pItem->m_filename.c_str(), pItem->m_Iconfilename.c_str(), pItem->m_itemType, pItem->m_item, pItem->m_status, pItem->m_equipSlot, pItem->m_itemQuality, pItem->m_title.c_str(), pItem->m_description.c_str(), pItem->m_left, pItem->m_right, pItem->m_placementR, pItem->m_placementG, pItem->m_placementB, pItem->m_quantity, slotX, slotY);

		for(int i = 0; i < (int)pItem->m_vpStatAttributes.size(); i++)
		{
			pAddedLootItem->AddStatAttribute(pItem->m_vpStatAttributes[i]->GetType(), pItem->m_vpStatAttributes[i]->GetModifyAmount());
		}

		return pAddedLootItem;
	}

	return NULL;
}
开发者ID:AlwaysGeeky,项目名称:Vox,代码行数:16,代码来源:Item.cpp

示例13: onDragDropItemDropped

//------------------------------------------------------------------------------//
void InventoryReceiver::onDragDropItemDropped(DragDropEventArgs &e)
{
    InventoryItem* item = dynamic_cast<InventoryItem*>(e.dragDropItem);

    if (!item)
        return;

    const Sizef square_size(squarePixelSize());

    Rectf item_area(item->getUnclippedOuterRect().get());
    item_area.offset(Vector2f(square_size.d_width / 2, square_size.d_height / 2));

    const int drop_x = gridXLocationFromPixelPosition(item_area.left());
    const int drop_y = gridYLocationFromPixelPosition(item_area.top());

    addItemAtLocation(*item, drop_x, drop_y);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:18,代码来源:InventoryReceiver.cpp

示例14: itemWillFitAtLocation

//------------------------------------------------------------------------------//
bool InventoryReceiver::itemWillFitAtLocation(const InventoryItem& item,
                                              int x, int y)
{
    if (x < 0 || y < 0)
        return false;

    if (x + item.contentWidth() > d_content.width() ||
        y + item.contentHeight() > d_content.height())
            return false;

    const bool already_attached = this == item.getParent();
    // if item is already attatched erase its data from the content map so the
    // test result is reliable.
    if (already_attached)
        eraseItemFromContentMap(item);

    bool result = true;
    for (int item_y = 0; item_y < item.contentHeight() && result; ++item_y)
    {
        for (int item_x = 0; item_x < item.contentWidth() && result; ++item_x)
        {
            if (d_content.elementAtLocation(item_x + x, item_y + y) &&
                item.isSolidAtLocation(item_x, item_y))
                    result = false;
        }
    }

    // re-write item into content map if we erased it earlier.
    if (already_attached)
        writeItemToContentMap(item);

    return result;
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:34,代码来源:InventoryReceiver.cpp

示例15: addItemAtLocation

//------------------------------------------------------------------------------//
bool InventoryReceiver::addItemAtLocation(InventoryItem& item, int x, int y)
{
    if (itemWillFitAtLocation(item, x, y))
    {
        InventoryReceiver* old_receiver =
            dynamic_cast<InventoryReceiver*>(item.getParent());

        if (old_receiver)
            old_receiver->removeItem(item);

        item.setLocationOnReceiver(x, y);
        writeItemToContentMap(item);
        addChild(&item);

        // set position and size.  This ensures the items visually match the
        // logical content map.


        item.setPosition(UVector2(UDim(static_cast<float>(x) / contentWidth(), 0),
                                  UDim(static_cast<float>(y) / contentHeight(), 0)));
        item.setSize(USize(
            UDim(static_cast<float>(item.contentWidth()) / contentWidth(), 0),
            UDim(static_cast<float>(item.contentHeight()) / contentHeight(), 0)));

        return true;
    }

    return false;
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:30,代码来源:InventoryReceiver.cpp


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