Affiche un Tooltip d'une unité quand on hover sur l'unité Inclus description et stats de l'unité Co-authored-by: Ader Alisma 01 <adeder22@hotmail.com> Reviewed-on: #6 Reviewed-by: EliaGingras1 <william-gin1@hotmail.com>
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using GatherAndDefend.Events;
|
|
using System;
|
|
using System.Diagnostics;
|
|
|
|
public class TooltipManager : Singleton<TooltipManager>
|
|
{
|
|
private string _description;
|
|
public string Description { get { return _description; } }
|
|
private string _hp;
|
|
public string Hp { get { return _hp; } }
|
|
private string _damage;
|
|
public string Damage { get { return _damage; } }
|
|
private string _attackSpeed;
|
|
public string AttackSpeed { get { return _attackSpeed; } }
|
|
private bool _tooltipVisibility;
|
|
public bool TooltipVisibility { get { return _tooltipVisibility; } }
|
|
|
|
public void ShowTooltip(UnitCard unitCard, string hp, string dmg, string atkSpeed, bool isNotTile = true)
|
|
{
|
|
string description = DescriptionManager(unitCard);
|
|
_tooltipVisibility = true;
|
|
_description = description;
|
|
if (hp.Equals("0") && isNotTile)
|
|
{
|
|
_hp = "1";
|
|
} else
|
|
{
|
|
_hp = hp;
|
|
}
|
|
_damage = dmg;
|
|
_attackSpeed = atkSpeed;
|
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
|
}
|
|
|
|
public void HideToolTip()
|
|
{
|
|
_tooltipVisibility = false;
|
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
|
}
|
|
|
|
private string DescriptionManager(UnitCard unitCard)
|
|
{
|
|
if (unitCard != null)
|
|
{
|
|
string tooltipDescription;
|
|
if (unitCard.TooltipString != null && unitCard.TooltipString.Length > 0)
|
|
{
|
|
tooltipDescription = unitCard.TooltipString;
|
|
}
|
|
else
|
|
{
|
|
tooltipDescription = "Exemple de description d'unité pour " + unitCard.name.ToLower();
|
|
}
|
|
return tooltipDescription;
|
|
}
|
|
return null;
|
|
}
|
|
}
|