예제 #1
0
    public void AddItem(QuestItem item)
    {
        ItemInfo info = FindItemInfo(item);

        /*if (info != null) {
         *      info.count++;
         *      info.slot.Count = info.count;
         *      return;
         * }*/

        GameObject    slotObj = Instantiate(slotPrefab.gameObject) as GameObject;
        QuestItemSlot slot    = slotObj.GetComponent <QuestItemSlot>();

        slot.Item  = item;
        slot.Count = 1;
        slot.transform.Reparent(slotsContainerGrid.transform);
        slotsContainerGrid.Reposition();

        info = new ItemInfo()
        {
            name = item.itemName, item = item, count = 1, slot = slot
        };

        items.Add(info);
    }
예제 #2
0
    public void RemoveItem(QuestItem item)
    {
        ItemInfo info = FindItemInfo(item);

        if (info == null)
        {
            Debug.LogError("Trying to remove item from inventory: " + item.itemName + ", no item");
            return;
        }

        if (info.count > 1)
        {
            info.count--;
            info.slot.Count = info.count;
            return;
        }

        QuestItemSlot slot = info.slot;

        items.Remove(info);
        Destroy(slot.gameObject);

        slotsContainerGrid.Reposition();
    }
예제 #3
0
 public void OnItemSlotPressed(QuestItemSlot slot)
 {
     Debug.Log("Pressed item slot with item " + slot.item.itemName);
 }