public override void OnDrop(PointerEventData eventData) { ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>(); if (itemDragHandler == null) { return; } InventorySlot inventorySlot = itemDragHandler.ItemSlotUI as InventorySlot; if (inventorySlot != null) { SlotItem = inventorySlot.ItemSlot.item; return; } HotbarSlot hotbarSlot = itemDragHandler.ItemSlotUI as HotbarSlot; if (hotbarSlot != null) { HotbarItem oldItem = SlotItem; SlotItem = hotbarSlot.SlotItem; hotbarSlot.SlotItem = oldItem; return; } }
public void Add(HotbarItem ItemToAdd) { foreach (HotbarSlot hotbarSlot in hotbarSlots) { if (hotbarSlot.AddItem(ItemToAdd)) { return; } } }
public bool AddItem(HotbarItem itemToAdd) { if (SlotItem != null) { return(false); } SlotItem = itemToAdd; return(true); }