コード例 #1
0
    public void AddItem(string itemName)
    {
        bool repeatedItem = false;

        updateLog.AddActionInLog("You got <" + itemName + ">");

        foreach (Item i in allItems.allItems)
        {
            if (itemName == i.name)
            {
                if (i.GetType() == typeof(HealingItem))
                {
                    foreach (Transform invenSlot in equipInven.transform)
                    {
                        if (invenSlot.childCount != 0)
                        {
                            DisplayItem itemDetails = invenSlot.GetChild(0).GetComponent <DisplayItem>();
                            if (itemDetails.name == i.name)  //player already got that item in his inven
                            {
                                itemDetails.AddItemCount();
                                repeatedItem = true;
                            }
                        }
                    }

                    if (repeatedItem == false)
                    {
                        InstantiateItem(i);
                    }
                }
                else
                {
                    InstantiateItem(i);
                }
            }
        }
    }