using UnityEngine; using UnityEngine.UI; using TMPro; using Ashwild.Inventory; namespace Ashwild.Crafting { /// /// A single ingredient cell in the crafting detail panel. Renders either a known ingredient /// (icon + required quantity, tinted by whether the player has enough) or a mystery placeholder /// ("?") for an ingredient the player has not discovered yet. /// public class IngredientSlotUI : MonoBehaviour { [SerializeField] private Image iconImage; [SerializeField] private TextMeshProUGUI quantityText; [Header("Mystery (undiscovered ingredient)")] [Tooltip("Icon shown for an ingredient the player hasn't discovered yet (a question mark).")] [SerializeField] private Sprite mysteryIcon; [Header("Colors")] [SerializeField] private Color enoughColor = Color.white; [SerializeField] private Color missingColor = new Color(1f, 0.3f, 0.3f, 1f); /// /// Renders a known ingredient: its icon and required amount, dimmed/red when the player lacks it. /// public void Setup(ItemData item, int required, int playerHas) { quantityText.gameObject.SetActive(true); iconImage.sprite = item.Icon; quantityText.text = "x" + required; quantityText.color = playerHas >= required ? enoughColor : missingColor; iconImage.color = playerHas >= required ? Color.white : new Color(1f, 1f, 1f, 0.5f); } /// /// Renders an undiscovered ingredient as a mystery: the "?" icon with no quantity text, so the /// player knows a craft exists but must still find what it needs and how much. /// public void SetupMystery() { iconImage.sprite = mysteryIcon; iconImage.color = new Color(1f, 1f, 1f, 0.5f); quantityText.gameObject.SetActive(false); } } }