public void CraftBtnClicked() { CraftingSlot selectedSlot = craftsHandler.GetSlotSelected(); foreach (Item s in selectedSlot.GetRecipe()) { Item removedItem = inventoryManager.GetItem(s); inventoryManager.RemoveItem(removedItem); } inventoryManager.AddItem(selectedSlot.GetItem()); craftButton.interactable = false; if (selectedSlot.GetItem().IsSameAs(Resources.Load <Gear>("Items/Gear/Radio"))) { pop.PopMessage(PopupSystem.Popup.Radio); } UpdateCraftable(); }
public void Show(CraftingSlot selectedItem) { Clear(); recipe = selectedItem.GetRecipe(); slots = new List <NumberSlot>(); GameObject obj; NumberSlot slot; int n = 1; Item previous = recipe[0]; for (int i = 1; i < recipe.Count; i++) { if (!previous.IsSameAs(recipe[i])) { obj = Instantiate(numberPrefab); slot = obj.GetComponent <NumberSlot>(); slot.AddItem(previous); slot.SetNumbers(getNumberInInvenotry(previous), n); obj.transform.SetParent(contentPanel.transform, false); slots.Add(slot); n = 1; } else { n++; } previous = recipe[i]; } obj = Instantiate(numberPrefab); slot = obj.GetComponent <NumberSlot>(); slot.AddItem(previous); slot.SetNumbers(getNumberInInvenotry(previous), n); obj.transform.SetParent(contentPanel.transform, false); slots.Add(slot); }