Centralized tooltip placeholder descriptions

This commit is contained in:
Ader Alisma 01 2024-12-08 14:11:21 -05:00
parent b7af95c232
commit 458da2371d
4 changed files with 23 additions and 34 deletions

View File

@ -14,8 +14,9 @@ public class TooltipManager : Singleton<TooltipManager>
private bool _tooltipVisibility;
public bool TooltipVisibility { get { return _tooltipVisibility; } }
public void ShowTooltip(string description, string hp, string dmg, string atkSpeed)
public void ShowTooltip(UnitCard unitCard, string hp, string dmg, string atkSpeed)
{
string description = DescriptionManager(unitCard);
_tooltipVisibility = true;
_description = description;
_hp = hp;
@ -24,9 +25,23 @@ public class TooltipManager : Singleton<TooltipManager>
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
}
internal void HideToolTip()
public void HideToolTip()
{
_tooltipVisibility = false;
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
}
private string DescriptionManager(UnitCard unitCard)
{
string tooltipDescription;
if (unitCard?.TooltipString.Length > 0)
{
tooltipDescription = unitCard.TooltipString;
}
else
{
tooltipDescription = "Exemple de description d'unité pour " + unitCard.name.ToLower();
}
return tooltipDescription;
}
}

View File

@ -85,17 +85,8 @@ public class GameObjectPlacementButton : UnitPlacementButton
public override void OnPointerEnter(PointerEventData eventData)
{
Ally go = _prefab.GetComponent<Ally>();
string tooltipDescription;
if (_unitCardInformation?.TooltipString.Length > 0)
{
tooltipDescription = _unitCardInformation.TooltipString;
}
else
{
tooltipDescription = "Exemple de description d'unité pour " + _unitCardInformation.name.ToLower();
}
TooltipManager.Instance.ShowTooltip(tooltipDescription, go.Hp.ToString(), go.AttackDamage.ToString(), go.AttackInterval.ToString());
Ally allyObj = _prefab.GetComponent<Ally>();
TooltipManager.Instance.ShowTooltip(_unitCardInformation, allyObj.Hp.ToString(), allyObj.AttackDamage.ToString(), allyObj.AttackInterval.ToString());
}
public override void OnPointerExit(PointerEventData eventData)

View File

@ -4,6 +4,7 @@ using UnityEngine.EventSystems;
public class TilePlacementButton : UnitPlacementButton
{
public LevelTile tile;
const string NULL = "0";
protected override bool CanPlace()
{
@ -25,16 +26,7 @@ public class TilePlacementButton : UnitPlacementButton
public override void OnPointerEnter(PointerEventData eventData)
{
string tooltipDescription;
if (_unitCardInformation?.TooltipString.Length > 0)
{
tooltipDescription = _unitCardInformation.TooltipString;
}
else
{
tooltipDescription = "Exemple de description de tuile pour " + _unitCardInformation.name.ToLower();
}
TooltipManager.Instance.ShowTooltip(tooltipDescription, "0", "0", "0");
TooltipManager.Instance.ShowTooltip(_unitCardInformation, NULL, NULL, NULL);
}
public override void OnPointerExit(PointerEventData eventData)

View File

@ -96,17 +96,8 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler, IPoin
}
public void OnPointerEnter(PointerEventData eventData)
{
Ally go = _prefab.GetComponent<Ally>();
string tooltipDescription;
if (_unitCardInformation.TooltipString.Length > 0)
{
tooltipDescription = _unitCardInformation.TooltipString;
}
else
{
tooltipDescription = "Exemple de description d'unité pour " + _unitCardInformation.name.ToLower();
}
TooltipManager.Instance.ShowTooltip(tooltipDescription, go.Hp.ToString(), go.AttackDamage.ToString(), go.AttackInterval.ToString());
Ally allyObj = _prefab.GetComponent<Ally>();
TooltipManager.Instance.ShowTooltip(_unitCardInformation, allyObj.Hp.ToString(), allyObj.AttackDamage.ToString(), allyObj.AttackInterval.ToString());
}
public void OnPointerExit(PointerEventData eventData)