Esempio n. 1
0
    private void DropHotbarOnInventory(SlotDragAndDrop draggued)
    {
        InventorySlot hotbarSlot = draggued.GetComponent <InventorySlot>();

        //emptySlot
        if (!dragable)
        {
            Hotbar.instance.Remove(hotbarSlot);
        }
        else
        {
            Hotbar.instance.AddItem(GetComponent <InventorySlot>().ItemStack, hotbarSlot);
        }
    }
Esempio n. 2
0
    private void DropOnHotbar(SlotDragAndDrop draggued)
    {
        InventorySlot dragguedSlot = draggued.GetComponent <InventorySlot>();
        InventorySlot thisSlot     = GetComponent <InventorySlot>();

        //hotbar to hotbar, just switch object position
        if (draggued.gameObject.CompareTag("hotbarSlot"))
        {
            Hotbar.instance.SwitchSlot(thisSlot, dragguedSlot);
        }
        else if (draggued.gameObject.CompareTag("InventorySlot"))
        {
            Hotbar.instance.BindItemInventoryWithSlot(dragguedSlot.ItemStack.item, thisSlot);
        }
    }
Esempio n. 3
0
//    private void DropEquipmentOnInventory(SlotDragAndDrop draggued)
//    {
//        EquipmentSlotScript equipmentSlot = draggued.gameObject.GetComponent<EquipmentSlotScript>();
//        ItemStack itemStack = GetComponent<InventorySlot>().ItemStack;
//
//        if (itemStack != null && itemStack.item.GetType() == typeof(Equipment))
//        {
//            // Equip the equipment of the received slot only if it's the same type equipmentSlot of the draggued object
//            // Correct the bug: drop a sword on helmet, then the sword isn't unequip and helmet is equip
//            Equipment equipment = (Equipment) itemStack.item;
//            if (equipment.equipSlot == equipmentSlot.equipmentSlot)
//            {
//                itemStack.item.Use();
//                return;
//            }
//        }
//
//        equipmentSlot.Unequip();
//    }

    private void SwitchInventoryItems(SlotDragAndDrop draggued)
    {
        // if empty, move object to the end of the list else, switch item place
        ItemStack itemStackDraggued = draggued.GetComponent <InventorySlot>().ItemStack;

        //emptySlot
        if (!dragable)
        {
            Debug.Log("Is Empty slot");
            Inventory.instance.MoveItemToLastIndex(itemStackDraggued.item);
        }
        else
        {
            Debug.Log("Is not Empty slot");
            ItemStack itemStack = GetComponent <InventorySlot>().ItemStack;
            Inventory.instance.SwitchItemInInventory(itemStack.item, itemStackDraggued.item);
        }
    }