public void InitUI(CraftingPlace _craftingPlace, Inventory _inventoryToAddItem, Inventory _inventoryToRemoveItem, CraftSO.CraftPlaceType craftPlaceType) { craftingPlace = _craftingPlace; inventoryToAddItem = _inventoryToAddItem; inventoryToRemoveItem = _inventoryToRemoveItem; craftingItems = new List <CraftingItemUI>(GameManager.Instance.crafts.Length); foreach (var craft in GameManager.Instance.crafts) { if (isHideUnavaliablePlaceCrafts && !craft.place.HasFlag(craftPlaceType)) { continue; } CraftingItemUI craftingItemUI = Instantiate(recipeGoPrefab, transform).GetComponent <CraftingItemUI>(); craftingItemUI.Init(craft, craftPlaceType, OnClickOnItem); craftingItems.Add(craftingItemUI); } cgSelectCraft.interactable = cgSelectCraft.blocksRaycasts = true; cgSelectCraft.alpha = 1.0f; cgCraftingPlace.interactable = cgCraftingPlace.blocksRaycasts = false; cgCraftingPlace.alpha = 0.0f; fillImage.fillAmount = 0; inventoryToRemoveItem.onInventoryChangeEvent += OnRemoveInventoryChange; craftingPlace.onUpdateCraftTimeFill += OnUpdateCraftTimeFill; craftingPlace.onEndCraft += OnEndCraft; }
void DrawIngredient(StationItem pItem) { CraftingItemUI itemUI = Instantiate(ItemUIPrefab, IngredientContainer); itemUI.Button.onClick.AddListener(delegate { Station.RemoveItem(pItem.ContainedItem); }); itemUI.IncreaseButton.onClick.AddListener(delegate { Station.IncreaseIngredientAmount(pItem); }); itemUI.DecreaseButton.onClick.AddListener(delegate { Station.DecreaseIngredientAmount(pItem); }); if (itemUI.Button != null) { itemUI.Button.interactable = false; } if (pItem != null) { if (itemUI.Button != null) { itemUI.Button.interactable = true; } itemUI.ItemIcon.color = Color.white; itemUI.ItemIcon.sprite = pItem.ContainedItem.Icon; itemUI.ItemAmount.text = "x" + pItem.Amount.ToString(); if (itemUI.ItemNameText != null) { itemUI.ItemNameText.text = pItem.ContainedItem.Name; } } else { if (itemUI.ItemNameText != null) { itemUI.ItemNameText.text = "No Recipe Selected"; } itemUI.ItemIcon.color = new Color(0, 0, 0, 0); itemUI.ItemAmount.text = ""; } DrawnItems.Add(itemUI); }
public void InitUI(CraftingPlace _craftingPlace, Inventory _inventoryToAddItem, Inventory _inventoryToRemoveItem, CraftSO.CraftPlaceType craftPlaceType) { craftingPlace = _craftingPlace; inventoryToAddItem = _inventoryToAddItem; inventoryToRemoveItem = _inventoryToRemoveItem; craftingItems = new List <CraftingItemUI>(GameManager.Instance.crafts.Length); foreach (var craft in GameManager.Instance.crafts) { if (isHideUnavaliablePlaceCrafts && !craft.place.HasFlag(craftPlaceType)) { continue; } CraftingItemUI craftingItemUI = Instantiate(recipeGoPrefab, transform).GetComponent <CraftingItemUI>(); craftingItemUI.Init(craft, craftPlaceType, OnClickOnItem); craftingItemUI.CheckIsEnoughIngradients(inventoryToRemoveItem); craftingItems.Add(craftingItemUI); } inventoryToRemoveItem.onInventoryChangeEvent += OnRemoveInventoryChange; craftingPlace.onUpdateCraftTimeFill += OnUpdateCraftTimeFill; craftingPlace.onEndCraft += OnEndCraft; }