Fixed display untouchable units

This commit is contained in:
Ader Alisma 01 2025-02-01 15:37:38 -05:00
parent dacd0f6b3c
commit 5c7d3e645d
4 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,6 @@
using GatherAndDefend.Events;
using System;
using System.Diagnostics;
public class TooltipManager : Singleton<TooltipManager>
{
@ -14,12 +15,18 @@ public class TooltipManager : Singleton<TooltipManager>
private bool _tooltipVisibility;
public bool TooltipVisibility { get { return _tooltipVisibility; } }
public void ShowTooltip(UnitCard unitCard, string hp, string dmg, string atkSpeed)
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();
@ -32,6 +39,8 @@ public class TooltipManager : Singleton<TooltipManager>
}
private string DescriptionManager(UnitCard unitCard)
{
if (unitCard)
{
string tooltipDescription;
if (unitCard?.TooltipString.Length > 0)
@ -44,4 +53,6 @@ public class TooltipManager : Singleton<TooltipManager>
}
return tooltipDescription;
}
return null;
}
}

View File

@ -30,7 +30,7 @@ public class TooltipText : MonoBehaviour
{
_tooltipPanel.SetActive(true);
_tooltipDescription.text = _tooltipManager.Description;
_tooltipHp.text = (_tooltipManager.Hp.Equals("0") ? "Ne peut pas être attaqué" : "Points de vie: " + _tooltipManager.Hp);
_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);
}

View File

@ -86,7 +86,6 @@ public class GameObjectPlacementButton : UnitPlacementButton
public override void OnPointerEnter(PointerEventData eventData)
{
Ally allyObj = _prefab.GetComponent<Ally>();
Debug.Log("For " + _unitCardInformation.name + ": " + allyObj.Hp);
TooltipManager.Instance.ShowTooltip(_unitCardInformation, allyObj.Hp.ToString(), allyObj.AttackDamage.ToString(), allyObj.AttackInterval.ToString());
}

View File

@ -26,7 +26,7 @@ public class TilePlacementButton : UnitPlacementButton
public override void OnPointerEnter(PointerEventData eventData)
{
TooltipManager.Instance.ShowTooltip(_unitCardInformation, NULL, NULL, NULL);
TooltipManager.Instance.ShowTooltip(_unitCardInformation, NULL, NULL, NULL, false);
}
public override void OnPointerExit(PointerEventData eventData)