61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System;
|
|
using Continentis.MainGame.Character;
|
|
using Lean.Pool;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class HUD_CharacterBuffIcon : HUD_BaseIcon
|
|
{
|
|
public CharacterBuffBase buff;
|
|
|
|
public void Initialize(CharacterBuffBase buff)
|
|
{
|
|
this.buff = buff;
|
|
buff.uiSubmodule.buffIcon = this;
|
|
|
|
icon.sprite = buff.uiSubmodule.icon;
|
|
|
|
UpdateIcon();
|
|
}
|
|
|
|
public override void UpdateIcon()
|
|
{
|
|
int index;
|
|
for (index = 0; index < buff.uiSubmodule.setTextFunctions.Count; index++)
|
|
{
|
|
var func = buff.uiSubmodule.setTextFunctions[index];
|
|
SetText(index, func);
|
|
}
|
|
|
|
if (index < textList.Count)
|
|
{
|
|
for (int i = index; i < textList.Count; i++)
|
|
{
|
|
textList[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
GameObject infoBoxPrefab = MainGameManager.Instance.basePrefabs.informationBox;
|
|
RectTransform canvasTransform = CombatUIManager.Instance.hudPage.rectTransform;
|
|
infoBox = LeanPool.Spawn(infoBoxPrefab, canvasTransform).GetComponent<InformationBox>();
|
|
|
|
infoBox.Initialize(buff.name, buff.description, canvasTransform.InverseTransformPoint(rectTransform.position));
|
|
}
|
|
|
|
public override void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
if (infoBox != null)
|
|
{
|
|
LeanPool.Despawn(infoBox.gameObject);
|
|
infoBox = null;
|
|
}
|
|
}
|
|
}
|
|
} |