(Feat) add crafting discovery + notification + inventory tool tips
This commit is contained in:
@@ -19,6 +19,7 @@ namespace Ashwild.UI
|
||||
private int totalQuantity;
|
||||
private float hideTimer;
|
||||
private bool isHiding;
|
||||
private bool isDiscovery;
|
||||
|
||||
private Tweener fadeTween;
|
||||
private Tweener slideTween;
|
||||
@@ -30,6 +31,9 @@ namespace Ashwild.UI
|
||||
// A notification is either a gain (+) or a loss (-); merging only happens within the same direction.
|
||||
public bool IsGain => totalQuantity >= 0;
|
||||
|
||||
// A discovery notification (icon + name + "NEW" badge) never merges with a gain/loss one.
|
||||
public bool IsDiscovery => isDiscovery;
|
||||
|
||||
public void Initialize(ItemData item, int signedQuantity, Color numberColor, float displayDuration, float slideInDuration, Ease slideInEase)
|
||||
{
|
||||
itemData = item;
|
||||
@@ -49,6 +53,34 @@ namespace Ashwild.UI
|
||||
fadeTween = canvasGroup.DOFade(1f, slideInDuration).SetEase(Ease.OutQuad);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a discovery notification: an icon and name (of the unlocked recipe) with a fixed
|
||||
/// badge (e.g. "NEW") in the number slot, tinted with the caller-chosen colour. It carries no
|
||||
/// quantity and never merges, so it reads as a one-time "recipe unlocked" cue.
|
||||
/// </summary>
|
||||
public void InitializeDiscovery(Sprite icon, string displayName, string badgeText, Color badgeColor, float displayDuration, float slideInDuration)
|
||||
{
|
||||
itemData = null;
|
||||
isDiscovery = true;
|
||||
hideTimer = displayDuration;
|
||||
isHiding = false;
|
||||
|
||||
if (iconImage != null)
|
||||
iconImage.sprite = icon;
|
||||
|
||||
if (labelText != null)
|
||||
labelText.text = displayName;
|
||||
|
||||
if (numberText != null)
|
||||
{
|
||||
numberText.text = badgeText;
|
||||
numberText.color = badgeColor;
|
||||
}
|
||||
|
||||
canvasGroup.alpha = 0f;
|
||||
fadeTween = canvasGroup.DOFade(1f, slideInDuration).SetEase(Ease.OutQuad);
|
||||
}
|
||||
|
||||
public void AddQuantity(int signedAmount, float displayDuration)
|
||||
{
|
||||
totalQuantity += signedAmount;
|
||||
|
||||
Reference in New Issue
Block a user