using BlueWater.Items; using UnityEngine; namespace BlueWater.Uis { public class IngredientItemSlotUi : TycoonItemSlotUi { [field: SerializeField] public bool IsEnoughIngredient { get; private set; } public override void SetItemSlot(ItemSlot itemSlot) { ItemSlot = itemSlot; ItemManager ??= ItemManager.Instance; if (IsLocked) { SetItemImage(ItemManager.ItemSlotDataSo.LockSprite); QuantityText.text = null; return; } if (ItemSlot == null) { SetItemImage(null); QuantityText.text = null; } else { SetItemImage(ItemManager.ItemDataSo.GetDataByIdx(ItemSlot.Idx).Sprite); var myIngredientQuantity = DataManager.Instance.Inventory.GetItemByIdx(itemSlot.Idx)?.Quantity ?? 0; var needQuantity = ItemSlot.Quantity; QuantityText.text = $"{myIngredientQuantity}/{needQuantity}"; IsEnoughIngredient = myIngredientQuantity - needQuantity >= 0; QuantityText.color = IsEnoughIngredient ? Color.white : Color.red; } } } }