(Feat) add crafting discovery + notification + inventory tool tips
This commit is contained in:
@@ -5,21 +5,45 @@ using Ashwild.Inventory;
|
||||
|
||||
namespace Ashwild.Crafting
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Renders a known ingredient: its icon and required amount, dimmed/red when the player lacks it.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public void SetupMystery()
|
||||
{
|
||||
iconImage.sprite = mysteryIcon;
|
||||
iconImage.color = new Color(1f, 1f, 1f, 0.5f);
|
||||
quantityText.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user