Fixed display untouchable units
This commit is contained in:
parent
dacd0f6b3c
commit
5c7d3e645d
@ -1,5 +1,6 @@
|
|||||||
using GatherAndDefend.Events;
|
using GatherAndDefend.Events;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
public class TooltipManager : Singleton<TooltipManager>
|
public class TooltipManager : Singleton<TooltipManager>
|
||||||
{
|
{
|
||||||
@ -14,12 +15,18 @@ public class TooltipManager : Singleton<TooltipManager>
|
|||||||
private bool _tooltipVisibility;
|
private bool _tooltipVisibility;
|
||||||
public bool TooltipVisibility { get { return _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);
|
string description = DescriptionManager(unitCard);
|
||||||
_tooltipVisibility = true;
|
_tooltipVisibility = true;
|
||||||
_description = description;
|
_description = description;
|
||||||
|
if (hp.Equals("0") && isNotTile)
|
||||||
|
{
|
||||||
|
_hp = "1";
|
||||||
|
} else
|
||||||
|
{
|
||||||
_hp = hp;
|
_hp = hp;
|
||||||
|
}
|
||||||
_damage = dmg;
|
_damage = dmg;
|
||||||
_attackSpeed = atkSpeed;
|
_attackSpeed = atkSpeed;
|
||||||
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
||||||
@ -32,6 +39,8 @@ public class TooltipManager : Singleton<TooltipManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string DescriptionManager(UnitCard unitCard)
|
private string DescriptionManager(UnitCard unitCard)
|
||||||
|
{
|
||||||
|
if (unitCard)
|
||||||
{
|
{
|
||||||
string tooltipDescription;
|
string tooltipDescription;
|
||||||
if (unitCard?.TooltipString.Length > 0)
|
if (unitCard?.TooltipString.Length > 0)
|
||||||
@ -44,4 +53,6 @@ public class TooltipManager : Singleton<TooltipManager>
|
|||||||
}
|
}
|
||||||
return tooltipDescription;
|
return tooltipDescription;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class TooltipText : MonoBehaviour
|
|||||||
{
|
{
|
||||||
_tooltipPanel.SetActive(true);
|
_tooltipPanel.SetActive(true);
|
||||||
_tooltipDescription.text = _tooltipManager.Description;
|
_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);
|
_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);
|
_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)
|
public override void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
Ally allyObj = _prefab.GetComponent<Ally>();
|
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());
|
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)
|
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)
|
public override void OnPointerExit(PointerEventData eventData)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user