public void Init(InventoryCell newCell = null, bool shouldFadeRed = false) { if (newCell == null) { if (recipe == null) { DeactivateComponents(); return; } cell = recipe.result; } else { cell = newCell; } _icon.sprite = cell.item.displayIcon; _count.text = cell.amount.ToString(); _icon.gameObject.SetActive(true); _count.gameObject.SetActive(true); if (shouldFadeRed) { _fader.GetComponent <Image>().color = new Color(1.0f, 0.0f, 0.0f, 0.39f); _fader.SetActive(true); } else { _fader.SetActive(false); } }
public void RemoveItem(Item item, int remainingItems = 0) { if (item == null) { Debug.LogWarning("Empty item to remove"); return; } InventoryCell holderForOutputItem = GetHolderByType(item.ItemType); if (holderForOutputItem == null) { return; } if (remainingItems > 0) { holderForOutputItem.ItemsCount.text = remainingItems.ToString(); return; } holderForOutputItem.CurrentItem = null; holderForOutputItem.Icon.sprite = null; holderForOutputItem.ItemName.text = "Empty"; holderForOutputItem.ItemsCount.text = ""; }
public void Init(InventoryWindow window, InventoryCell inventoryCell, InventorySlotType _slotType = InventorySlotType.PrevSet) { _window = window; _cell = inventoryCell; slotType = _slotType == InventorySlotType.PrevSet ? slotType : _slotType; actionButton[0].gameObject.SetActive(true); SetupFromCell(); if (_cell != null) { _count.gameObject.SetActive(true); _count.SetText(_cell.amount > 1 ? _cell.amount.ToString() : ""); } else { _count.gameObject.SetActive(false); } }
public void DisplayItem(Item item, int count) { if (item == null) { Debug.LogWarning("Empty item to remove"); return; } InventoryCell holderForInputItem = GetHolderByType(item.ItemType); if (holderForInputItem == null) { return; } holderForInputItem.CurrentItem = item; holderForInputItem.Icon.sprite = item.Icon; holderForInputItem.ItemName.text = item.ItemName; holderForInputItem.ItemsCount.text = count.ToString(); }