void Craft() { if (craftingSlots[0].slotInteractable != null && craftingSlots[1].slotInteractable != null) { for (int i = 0; i < craftingRecipes.Length; i++) { Item a = craftingRecipes[i].Materials[0].item; int aa = craftingRecipes[i].Materials[0].Amount; Item b = craftingRecipes[i].Materials[1].item; int ba = craftingRecipes[i].Materials[1].Amount; if (craftingSlots[0].slotInteractable.item == a && craftingSlots[0].slotItemAmount.Equals(aa)) { if (craftingSlots[1].slotInteractable.item == b && craftingSlots[1].slotItemAmount.Equals(ba)) { foreach (CraftingSlot x in craftingSlots) { x.RemoveItem(); } result = craftingRecipes[i].Result.GetComponent <Interactable>(); productSlot.AddItem(result, 1); NoticeManager.instance.setText("成功合成" + result.item.name); NoticeManager.instance.noticeOnOff(); source.PlayOneShot(craftSound); } } else if (craftingSlots[0].slotInteractable.item == b && craftingSlots[0].slotItemAmount.Equals(ba)) { if (craftingSlots[1].slotInteractable.item == a && craftingSlots[1].slotItemAmount.Equals(aa)) { foreach (CraftingSlot x in craftingSlots) { x.RemoveItem(); } result = craftingRecipes[i].Result.GetComponent <Interactable>(); productSlot.AddItem(result, 1); NoticeManager.instance.setText("成功合成" + result.item.name); NoticeManager.instance.noticeOnOff(); source.PlayOneShot(craftSound); } } } } else { NoticeManager.instance.setText("擺啦仲唔擺?"); NoticeManager.instance.noticeOnOff(); } }
public void SetCurrentRecipe(QI_CraftingRecipe itemToCraft) { ClearCurrentRecipe(); craftableItem = itemToCraft; craftedSlot.AddItem(craftableItem.Product.Item, craftableItem.Product.Amount, this); for (int i = 0; i < craftableItem.Ingredients.Count; i++) { ingredientSlots[i].AddItem(craftableItem.Ingredients[i].Item, craftableItem.Ingredients[i].Amount, inventory.GetStock(craftableItem.Ingredients[i].Item.Name)); } }
public void Show() { Clear(); slots = new List <CraftingSlot>(); foreach (Item item in craftingList) { GameObject obj = Instantiate(craftPrefab); CraftingSlot slot = obj.GetComponent <CraftingSlot>(); slot.inventoryManager = inventoryManager; slot.craftsHandler = this; slot.AddItem(Instantiate(item)); obj.transform.SetParent(contentPanel.transform, false); slots.Add(slot); } }