Example #1
0
        public void AddItemToRespectiveSlot(InventoryItemButton itemButton)
        {
            switch (itemButton.ItemSlot)
            {
            case ItemSlot.Weapon:
                if (!weaponSlot1.Occupied)
                {
                    weaponSlot1.AddItemIntoSlot(itemButton);
                }
                else
                {
                    weaponSlot2.AddItemIntoSlot(itemButton);
                }
                break;

            case ItemSlot.Head:
                headSlot.AddItemIntoSlot(itemButton);
                break;

            case ItemSlot.Body:
                bodySlot.AddItemIntoSlot(itemButton);
                break;

            case ItemSlot.Feet:
                feetSlot.AddItemIntoSlot(itemButton);
                break;
            }
        }
        public void OnDrop(PointerEventData eventData)
        {
            InventoryItemButton itemButton = ItemDragHandler.selectedItemButton;

            if (CanMoveToSlot())
            {
                if (!string.IsNullOrEmpty(_slotDetail.ItemName))
                {
                    //_slotDetail.RemoveItemFromSlot();
                    InventoryManager.Instance.MoveItemToInventory(_slotDetail.ItemName);
                }

                string itemName = itemButton.ItemName;
                _slotDetail.AddItemIntoSlot(itemButton);
                itemButton.DisableDrag();
                InventoryManager.Instance.AddAttributeIntoOverallStats(itemName);
            }
            else
            {
                itemButton.ResetParent();
            }

            itemButton.GetComponent <CanvasGroup>().blocksRaycasts = true;
            ItemDragHandler.selectedItemButton = null;
        }