private void OnEnable() //Quando um objeto do inventario for selecionado, entao os botoes devem aparecer. { selectedSlot = null; optionOnSelect.SetActive(false); buttonEquip.SetActive(true); buttonUse.SetActive(true); }
public void AddItemToInventory(ItensBase item, bool delete = false) // adiciona um item ao inventario, testa se é Stack ou não. { bool foundItem = false; SlotInventarioBehaviour slotVazio = proxSlotVazio(); if (item.isStacklabe) { foreach (SlotInventarioBehaviour slot in InventarioSlots) { if (slot.currentItem != null && slot.currentItem.nameItem == item.nameItem) { slot.currentItem.addItem(); foundItem = true; if (delete) { item.DestroiItem(); } } } if (!foundItem && slotVazio != null) { slotVazio.currentItem = item; } } else if (slotVazio != null) { slotVazio.currentItem = item; } if (!delete) { item.gameObject.SetActive(false); } }
private SlotInventarioBehaviour proxSlotVazio() //aponta o proximo slot vazio { SlotInventarioBehaviour slotToReturn = null; foreach (SlotInventarioBehaviour slot in InventarioSlots) { if (slot.currentItem == null) { slotToReturn = slot; break; } } return(slotToReturn); }