47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using GatherAndDefend.Events;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class TooltipText : MonoBehaviour
|
|
{
|
|
private TooltipManager _tooltipManager;
|
|
[SerializeField]
|
|
private GameObject _tooltipPanel;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _tooltipDescription;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _tooltipHp;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _tooltipDmg;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _tooltipAttackSpeed;
|
|
private const string EMPTY_STRING = "";
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
_tooltipManager = TooltipManager.Instance;
|
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Attach(OnEventUpdate);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void OnEventUpdate()
|
|
{
|
|
if (_tooltipManager.TooltipVisibility)
|
|
{
|
|
_tooltipPanel.SetActive(true);
|
|
_tooltipDescription.text = _tooltipManager.Description;
|
|
_tooltipHp.text = (_tooltipManager.Hp.Equals("0") ? ("Intouchable") : "Points de vie: " + _tooltipManager.Hp);
|
|
_tooltipDmg.text = (_tooltipManager.Damage.Equals("0") ? "Ne peut pas attaquer" : "Dommage: " + _tooltipManager.Damage);
|
|
_tooltipAttackSpeed.text = (_tooltipManager.Damage.Equals("0") ? EMPTY_STRING : "Vitesse d'attaque: " + _tooltipManager.AttackSpeed);
|
|
}
|
|
else
|
|
{
|
|
_tooltipPanel.SetActive(false);
|
|
_tooltipDescription.text = EMPTY_STRING;
|
|
_tooltipHp.text = EMPTY_STRING;
|
|
_tooltipDmg.text = EMPTY_STRING;
|
|
_tooltipAttackSpeed.text = EMPTY_STRING;
|
|
}
|
|
}
|
|
}
|