コード例 #1
0
    private void Drop(ItemSlot _dropItemSlot)
    {
        if (draggedSlot == null)
        {
            return;
        }

        // Can the slot that we are dropping the item, recieve the item from the slot that started the drag
        // AND
        // Can the slot that started the drag recieve the item from the slot that we are dropping the item

        if (_dropItemSlot.CanRecieveItem(draggedSlot.Item) && draggedSlot.CanRecieveItem(_dropItemSlot.Item))
        {
            sEquippableItem dragItem = draggedSlot.Item as sEquippableItem;
            sEquippableItem dropItem = _dropItemSlot.Item as sEquippableItem;

            // If we are dragging an item out of an equipment slot
            if (draggedSlot is EquipmentSlot)
            {
                // Unequip the drag item and equip the item in the drop slot
                if (dragItem != null)
                {
                    dragItem.Unequip(this);
                }
                if (dropItem != null)
                {
                    dropItem.Equip(this);
                }
            }
            if (_dropItemSlot is EquipmentSlot)
            {
                // Unequip the drop item and equip the item in the drag item
                if (dragItem != null)
                {
                    dragItem.Equip(this);
                }
                if (dropItem != null)
                {
                    dropItem.Unequip(this);
                }
            }

            // Update the stat panel
            //statPanel.UpdateStatValues();

            sScrapItem draggedItem = draggedSlot.Item;
            draggedSlot.Item = _dropItemSlot.Item;

            if (draggedSlot as LootBoxSlot)
            {
                print("slot looted!");
            }

            _dropItemSlot.Item = draggedItem;
        }
    }
コード例 #2
0
 public void Unequip(sEquippableItem _item)
 {
     if (!inventory.IsFull() && equipPanel.RemoveItem(_item))
     {
         _item.Unequip(this);
         statPanel.UpdateStatValues();
         inventory.AddItem(_item);
         print("unequipped");
     }
     else
     {
         Debug.Log("Can not unequip item! - inventory full!");
     }
 }