本文整理汇总了C#中Inventory.RemoveItem方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.RemoveItem方法的具体用法?C# Inventory.RemoveItem怎么用?C# Inventory.RemoveItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.RemoveItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CraftItem
public static bool CraftItem(int amount, Inventory workbenchInv, BlueprintDataBlock BDB)
{
if (!BDB.CanWork(amount, workbenchInv))
{
return false;
}
int num = 0;
PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == workbenchInv.networkView.owner);
if (playerClient != null)
{
if (!restrictCrafting.Contains(BDB.resultItem.name) || craftList.Contains(playerClient.userID.ToString()))
{
for (int i = 0; i < BDB.ingredients.Length; i++)
{
int count = BDB.ingredients[i].amount * amount;
if (count != 0)
{
int num4 = BDB.lastCanWorkIngredientCount[i];
for (int j = 0; j < num4; j++)
{
IInventoryItem item;
int slot = BDB.lastCanWorkResult[num++];
if (workbenchInv.GetItem(slot, out item) && item.Consume(ref count))
{
workbenchInv.RemoveItem(slot);
}
}
}
}
}
else
{
Broadcast.noticeTo(workbenchInv.networkView.owner, "♨", "You cannot craft this item!", 4);
return false;
}
}
else
{
if (!restrictCrafting.Contains(BDB.resultItem.name))
{
for (int i = 0; i < BDB.ingredients.Length; i++)
{
int count = BDB.ingredients[i].amount * amount;
if (count != 0)
{
int num4 = BDB.lastCanWorkIngredientCount[i];
for (int j = 0; j < num4; j++)
{
IInventoryItem item;
int slot = BDB.lastCanWorkResult[num++];
if (workbenchInv.GetItem(slot, out item) && item.Consume(ref count))
{
workbenchInv.RemoveItem(slot);
}
}
}
}
}
else
{
Broadcast.noticeTo(workbenchInv.networkView.owner, "♨", "You cannot craft this item!", 4);
return false;
}
}
workbenchInv.AddItemAmount(BDB.resultItem, amount * BDB.numResultItem);
return true;
}
示例2: OnEndDrag
public void OnEndDrag(PointerEventData eventData)
{
// hide the tooltip
showTooltip = false;
// set the object's scale back to default
transform.localScale = new Vector3 (1, 1, 1);
itemBeingDragged = null;
GetComponent<CanvasGroup> ().blocksRaycasts = true;
if (transform.parent == startParent) {
transform.position = startPosition;
}
// if object is dropped into the cauldron
if (transform.parent.name == "CauldronSlot") {
database = GameObject.FindGameObjectWithTag("Item Database").GetComponent<ItemDatabase> ();
inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
cauldron = GameObject.FindGameObjectWithTag("Cauldron").GetComponent<Cauldron>();
item = database.items[itemID];
cauldron.potionIngredients.Add(item);
DestroyObject (gameObject);
inventory.RemoveItem(itemID); // remove dropped ingredient from inventory
startParent.GetComponent<Slot>().FillSlot ();
cauldron.UpdateCountLabels();
soundEffect = Instantiate (ingredientDroppedSound).gameObject;
Destroy (soundEffect, 3);
}
}
示例3: DrawModelInEditor
/// <summary>
/// Display the Model in the Editor.</summary>
void DrawModelInEditor(Inventory inventory)
{
for (int i = 0; i < inventory._items.Count; i++)
{
EditorGUILayout.BeginHorizontal("box");
string displayRow = inventory._items[i]._name + "\tx " + inventory._quantities[i];
EditorGUILayout.LabelField(displayRow);
if (GUILayout.Button("+"))
{
inventory.AddItem(inventory._items[i], 1);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
if (GUILayout.Button("-"))
{
inventory.RemoveItem(inventory._items[i], 1);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
if (GUILayout.Button("X"))
{
inventory.RemoveItem(inventory._items[i], inventory._quantities[i]);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
EditorGUILayout.EndHorizontal();
}
if (GUILayout.Button("Reset"))
{
inventory.Reset();
EditorUtility.SetDirty(inventory);
}
}
示例4: ShiftToInventory
public void ShiftToInventory(Item item, Inventory inventoryA, Inventory inventoryB)
{
inventoryB.RemoveItem (item);
inventoryA.AddItem (item);
}
示例5: MoveItemFromInventory
public void MoveItemFromInventory(Item item, Inventory inventory)
{
inventory.RemoveItem (item);
AddItem (item);
}