public void SetIntoInventoriesShortcut(UISlotType type, Item item, int slot) { switch (type) { case UISlotType.hotbar: hotbar[slot] = item; if (UI.hotbarUI.initialized) { UI.SetIconTo(type, item, slot); } break; case UISlotType.inventory: inventory[slot] = item; if (UI.inventoryUI.initialized) { UI.SetIconTo(type, item, slot); } break; } }
public void MoveInInventory(UISlotType previousType, int previousNumber, Item previousItem, UISlotType nextType, int nextNumber, Item nextItem) { switch (previousType) { case UISlotType.hotbar: hotbar[previousNumber] = previousItem; break; case UISlotType.inventory: inventory[previousNumber] = previousItem; break; } switch (nextType) { case UISlotType.hotbar: hotbar[nextNumber] = nextItem; break; case UISlotType.inventory: inventory[nextNumber] = nextItem; break; } currentItem = hotbar[GetCurrentItemNum()]; }
public void RemoveForPlacing(UISlotType type) { UI.SetIconTo(type, null, GetCurrentItemNum()); RemoveFromInventory(type, GetCurrentItemNum(), currentItem.gameObject); currentItem = hotbar[GetCurrentItemNum()]; }
public Slot CreateSlot(BaseUI inventory, UISlotType type, Transform soonToBeParent, int slotNumber) { GameObject clone = Instantiate(Resources.Load("UI/Slot"), soonToBeParent) as GameObject; Slot slot = clone.GetComponent <Slot>(); slot.slotNumber = slotNumber; slot.slotType = type; slot.inventory = inventory; slot.UI = this; return(slot); }
public void RemoveFromInventory(UISlotType type, int slotNumber, GameObject toDestroy) { switch (type) { case UISlotType.hotbar: hotbar[slotNumber] = null; break; case UISlotType.inventory: inventory[slotNumber] = null; break; } Destroy(toDestroy); }
Item FindDuplicates(UISlotType type, Item current) { Item dupe = null; switch (type) { case UISlotType.hotbar: dupe = hotbar.Find(myItem => myItem != null && myItem.getItemName() == current.getItemName() && myItem.getHowMany() < myItem.getStackSize()); break; case UISlotType.inventory: dupe = inventory.Find(myItem => myItem != null && myItem.getItemName() == current.getItemName() && myItem.getHowMany() < myItem.getStackSize()); break; } return(dupe); }
public void SetIconTo(UISlotType type, Item item, int slot) { List <ItemData> toDelete = new List <ItemData>(); switch (type) { case UISlotType.hotbar: if (hotbarUI.initialized) { toDelete.Add(hotbarUI.hotSlots[slot].itemData); SetIconFor(UITypes.hotbarUI_hotslots, item, hotbarUI.hotSlots[slot]); } if (inventoryUI.initialized) { toDelete.Add(inventoryUI.hotSlots[slot].itemData); SetIconFor(UITypes.inventoryUI_hotSlots, item, inventoryUI.hotSlots[slot]); } if (mechanismUI.initialized) { toDelete.Add(mechanismUI.hotSlots[slot].itemData); SetIconFor(UITypes.mechanismUI_hotSlots, item, mechanismUI.hotSlots[slot]); } break; case UISlotType.inventory: if (inventoryUI.initialized) { toDelete.Add(inventoryUI.invSlots[slot].itemData); SetIconFor(UITypes.inventoryUI_invSlots, item, inventoryUI.invSlots[slot]); } if (mechanismUI.initialized) { toDelete.Add(mechanismUI.invSlots[slot].itemData); SetIconFor(UITypes.mechanismUI_invSlots, item, mechanismUI.invSlots[slot]); } break; } foreach (ItemData go in toDelete) { Destroy(go.gameObject); } }
public void SetSlotFor(UISlotType slotType, UITypes type, int slotNumber) { switch (slotType) { case UISlotType.hotbar: switch (type) { case UITypes.hotbarUI_hotslots: hotbarUI.hotSlots.Add(CreateSlot(hotbarUI, slotType, hotbarUI.hotbarGo.transform, slotNumber)); break; case UITypes.inventoryUI_hotSlots: inventoryUI.hotSlots.Add(CreateSlot(inventoryUI, slotType, inventoryUI.hotbarGo.transform, slotNumber)); break; case UITypes.mechanismUI_hotSlots: mechanismUI.hotSlots.Add(CreateSlot(mechanismUI, slotType, mechanismUI.hotbarGo.transform, slotNumber)); break; default: Debug.Log("None set for " + type.ToString()); break; } break; case UISlotType.inventory: switch (type) { case UITypes.inventoryUI_invSlots: inventoryUI.invSlots.Add(CreateSlot(inventoryUI, slotType, inventoryUI.inventoryGo.transform, slotNumber)); break; case UITypes.mechanismUI_invSlots: mechanismUI.invSlots.Add(CreateSlot(mechanismUI, slotType, mechanismUI.inventoryGo.transform, slotNumber)); break; default: Debug.Log("None set for " + type.ToString()); break; } break; } }