Added Unit Tooltip #6
@ -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;
|
||||
_hp = hp;
|
||||
if (hp.Equals("0") && isNotTile)
|
||||
{
|
||||
_hp = "1";
|
||||
} else
|
||||
{
|
||||
_hp = hp;
|
||||
}
|
||||
_damage = dmg;
|
||||
_attackSpeed = atkSpeed;
|
||||
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
||||
@ -33,15 +40,19 @@ public class TooltipManager : Singleton<TooltipManager>
|
||||
|
||||
private string DescriptionManager(UnitCard unitCard)
|
||||
{
|
||||
string tooltipDescription;
|
||||
if (unitCard?.TooltipString.Length > 0)
|
||||
if (unitCard)
|
||||
{
|
||||
tooltipDescription = unitCard.TooltipString;
|
||||
string tooltipDescription;
|
||||
if (unitCard?.TooltipString.Length > 0)
|
||||
{
|
||||
tooltipDescription = unitCard.TooltipString;
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipDescription = "Exemple de description d'unité pour " + unitCard.name.ToLower();
|
||||
}
|
||||
return tooltipDescription;
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipDescription = "Exemple de description d'unité pour " + unitCard.name.ToLower();
|
||||
}
|
||||
return tooltipDescription;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user