本文整理汇总了C++中ItemBase::GetItemNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemBase::GetItemNumber方法的具体用法?C++ ItemBase::GetItemNumber怎么用?C++ ItemBase::GetItemNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemBase
的用法示例。
在下文中一共展示了ItemBase::GetItemNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void Inventory::Update(float deltaTime) {
mDragSprite.Update(deltaTime);
int x = Input_GetMouseScreenX();
int y = Input_GetMouseScreenY();
int dragSpriteX = mDragSprite.GetPosition().x;
int dragSpriteY = mDragSprite.GetPosition().y;
int width = mDragSprite.GetSpriteWidth();
int height = mDragSprite.GetSpriteHeight();
// Check for item use
if (((x > dragSpriteX) && x < dragSpriteX + width)
&& (y > dragSpriteY && y < dragSpriteY + height)
&& mDragSprite.GetVisible()) {
bool mouseDown = Input_IsMousePressed(Mouse::LBUTTON);
SVector2 position = mDragSprite.GetPosition();
float x = Input_GetMouseScreenX() - position.x;
float y = Input_GetMouseScreenY() - position.y - 32;
// Exit Button
if (mouseDown && x > 264 && x < 286 && y < 0) {
mDragSprite.ToggleVisible();
}
int itemSlot = -1;
// Figure out what item we are selecting
int xSlot = -1;
if (x > 27 && x < 70)
xSlot = 0;
if (x > 78 && x < 120)
xSlot = 1;
if (x > 127 && x < 170)
xSlot = 2;
if (x > 178 && x < 218)
xSlot = 3;
if (x > 226 && x < 270)
xSlot = 4;
int ySlot = -1;
if (y > -4 && y < 34)
ySlot = 0;
if (y > 46 && y < 85)
ySlot = 1;
if (y > 93 && y < 135)
ySlot = 2;
if (y > 143 && y < 183)
ySlot = 3;
if (y > 192 && y < 234)
ySlot = 4;
if (y > 242 && y < 282)
ySlot = 5;
if (xSlot >= 0 && ySlot >= 0) {
itemSlot = xSlot + ySlot * 5;
}
if (mouseDown) {
if (itemSlot >= 0 && itemSlot < mItems.size()) {
mItems[itemSlot]->UseItem(mPlayerInfo, mRaknet);
mItems.erase(mItems.begin() + itemSlot);
}
}
if (Input_IsMousePressed(Mouse::RBUTTON)) {
// Delete Item in slot
if (itemSlot >= 0 && itemSlot < mItems.size()) {
ItemBase* item = mItems[itemSlot];
int imageNumber = item->GetImageNumber();
mItems.erase(mItems.begin() + itemSlot);
// Let the server know we droped a item
RakNet::BitStream bsOut;
bsOut.Write((RakNet::MessageID) ID_DROP_ITEM);
bsOut.Write(mPlayerInfo.GetMap());
bsOut.Write(imageNumber);
bsOut.Write(item->GetItemNumber());
bsOut.Write(mCharacter.GetTileIndex());
mRaknet.mPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0,
mRaknet.mServerAddress, false);
}
}
}
}