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


C# Inventory.RemoveItem方法代码示例

本文整理汇总了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;
 }
开发者ID:TheOneAndOnlyLoki,项目名称:RustEssentials,代码行数:67,代码来源:Vars.cs

示例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);
        }
    }
开发者ID:jopesy,项目名称:The-Alchemist,代码行数:28,代码来源:DragHandler.cs

示例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);
        }
    }
开发者ID:PaulSchweizer,项目名称:GameDev,代码行数:40,代码来源:InventoryEditor.cs

示例4: ShiftToInventory

 public void ShiftToInventory(Item item, Inventory inventoryA, Inventory inventoryB)
 {
     inventoryB.RemoveItem (item);
     inventoryA.AddItem (item);
 }
开发者ID:Antrum,项目名称:Unity,代码行数:5,代码来源:InventoryManager.cs

示例5: MoveItemFromInventory

 public void MoveItemFromInventory(Item item, Inventory inventory)
 {
     inventory.RemoveItem (item);
     AddItem (item);
 }
开发者ID:Antrum,项目名称:Unity,代码行数:5,代码来源:Equip.cs


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