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); }
private void SetItemQuantityUI() { if (SlotItem is InventoryItem inventoryItem) { if (inventory.ItemContainer.HasItem(inventoryItem)) { int quantityCount = inventory.ItemContainer.GetTotalQuantity(inventoryItem); itemQuantityText.text = quantityCount > 1 ? quantityCount.ToString() : ""; } else { SlotItem = null; } } else { itemQuantityText.enabled = false; } }