Added Unit Tooltip #6
@ -14,8 +14,9 @@ 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(string description, string hp, string dmg, string atkSpeed)
|
public void ShowTooltip(UnitCard unitCard, string hp, string dmg, string atkSpeed)
|
||||||
{
|
{
|
||||||
|
string description = DescriptionManager(unitCard);
|
||||||
_tooltipVisibility = true;
|
_tooltipVisibility = true;
|
||||||
_description = description;
|
_description = description;
|
||||||
_hp = hp;
|
_hp = hp;
|
||||||
@ -24,9 +25,23 @@ public class TooltipManager : Singleton<TooltipManager>
|
|||||||
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void HideToolTip()
|
public void HideToolTip()
|
||||||
{
|
{
|
||||||
_tooltipVisibility = false;
|
_tooltipVisibility = false;
|
||||||
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
EventAggregator.Instance.GetEvent<TooltipChangedEvent>().Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string DescriptionManager(UnitCard unitCard)
|
||||||
|
{
|
||||||
|
string tooltipDescription;
|
||||||
|
if (unitCard?.TooltipString.Length > 0)
|
||||||
|
{
|
||||||
|
tooltipDescription = unitCard.TooltipString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tooltipDescription = "Exemple de description d'unité pour " + unitCard.name.ToLower();
|
||||||
|
}
|
||||||
|
return tooltipDescription;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,17 +85,8 @@ public class GameObjectPlacementButton : UnitPlacementButton
|
|||||||
|
|
||||||
public override void OnPointerEnter(PointerEventData eventData)
|
public override void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
Ally go = _prefab.GetComponent<Ally>();
|
Ally allyObj = _prefab.GetComponent<Ally>();
|
||||||
string tooltipDescription;
|
TooltipManager.Instance.ShowTooltip(_unitCardInformation, allyObj.Hp.ToString(), allyObj.AttackDamage.ToString(), allyObj.AttackInterval.ToString());
|
||||||
if (_unitCardInformation?.TooltipString.Length > 0)
|
|
||||||
{
|
|
||||||
tooltipDescription = _unitCardInformation.TooltipString;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tooltipDescription = "Exemple de description d'unité pour " + _unitCardInformation.name.ToLower();
|
|
||||||
}
|
|
||||||
TooltipManager.Instance.ShowTooltip(tooltipDescription, go.Hp.ToString(), go.AttackDamage.ToString(), go.AttackInterval.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPointerExit(PointerEventData eventData)
|
public override void OnPointerExit(PointerEventData eventData)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using UnityEngine.EventSystems;
|
|||||||
public class TilePlacementButton : UnitPlacementButton
|
public class TilePlacementButton : UnitPlacementButton
|
||||||
{
|
{
|
||||||
public LevelTile tile;
|
public LevelTile tile;
|
||||||
|
const string NULL = "0";
|
||||||
|
|
||||||
protected override bool CanPlace()
|
protected override bool CanPlace()
|
||||||
{
|
{
|
||||||
@ -25,16 +26,7 @@ public class TilePlacementButton : UnitPlacementButton
|
|||||||
|
|
||||||
public override void OnPointerEnter(PointerEventData eventData)
|
public override void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
string tooltipDescription;
|
TooltipManager.Instance.ShowTooltip(_unitCardInformation, NULL, NULL, NULL);
|
||||||
if (_unitCardInformation?.TooltipString.Length > 0)
|
|
||||||
{
|
|
||||||
tooltipDescription = _unitCardInformation.TooltipString;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tooltipDescription = "Exemple de description de tuile pour " + _unitCardInformation.name.ToLower();
|
|
||||||
}
|
|
||||||
TooltipManager.Instance.ShowTooltip(tooltipDescription, "0", "0", "0");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPointerExit(PointerEventData eventData)
|
public override void OnPointerExit(PointerEventData eventData)
|
||||||
|
|||||||
@ -96,17 +96,8 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler, IPoin
|
|||||||
}
|
}
|
||||||
public void OnPointerEnter(PointerEventData eventData)
|
public void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
Ally go = _prefab.GetComponent<Ally>();
|
Ally allyObj = _prefab.GetComponent<Ally>();
|
||||||
string tooltipDescription;
|
TooltipManager.Instance.ShowTooltip(_unitCardInformation, allyObj.Hp.ToString(), allyObj.AttackDamage.ToString(), allyObj.AttackInterval.ToString());
|
||||||
if (_unitCardInformation.TooltipString.Length > 0)
|
|
||||||
{
|
|
||||||
tooltipDescription = _unitCardInformation.TooltipString;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tooltipDescription = "Exemple de description d'unité pour " + _unitCardInformation.name.ToLower();
|
|
||||||
}
|
|
||||||
TooltipManager.Instance.ShowTooltip(tooltipDescription, go.Hp.ToString(), go.AttackDamage.ToString(), go.AttackInterval.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerExit(PointerEventData eventData)
|
public void OnPointerExit(PointerEventData eventData)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user