本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例3: fireCondition
bool AICurrentItemCondition::fireCondition() {
InventoryItem *item = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
if (_item == kNoItemID)
return item == 0;
return item != 0 && item->getObjectID() == _item;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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 );
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}