81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using Logic.Skill;
|
|
using RuntimeData;
|
|
using TH1_Logic.Core;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_Renderer
|
|
{
|
|
public class StatusIconMono : MonoBehaviour
|
|
{
|
|
public Image SkillIcon;
|
|
public GameObject SkillLevelObj;
|
|
public TextMeshProUGUI SkillLevelText;
|
|
|
|
private void Awake()
|
|
{
|
|
EnsureRefs();
|
|
}
|
|
|
|
private void EnsureRefs()
|
|
{
|
|
if (SkillIcon == null)
|
|
{
|
|
SkillIcon = GetComponent<Image>();
|
|
}
|
|
|
|
if (SkillLevelObj == null)
|
|
{
|
|
var levelTf = transform.Find("Level");
|
|
if (levelTf != null)
|
|
{
|
|
SkillLevelObj = levelTf.gameObject;
|
|
}
|
|
}
|
|
|
|
if (SkillLevelText == null && SkillLevelObj != null)
|
|
{
|
|
SkillLevelText = SkillLevelObj.GetComponentInChildren<TextMeshProUGUI>(true);
|
|
}
|
|
}
|
|
|
|
public void SetContent(SkillType skillType, UnitFullType unitFullType, bool hasLevel, int level)
|
|
{
|
|
EnsureRefs();
|
|
|
|
if (SkillIcon != null && Table.Instance.SkillDataAssets.GetSkillIcon(skillType, unitFullType, out var icon))
|
|
{
|
|
SkillIcon.sprite = icon;
|
|
}
|
|
|
|
bool showLevel = hasLevel && level > 1;
|
|
if (SkillLevelObj != null)
|
|
{
|
|
SkillLevelObj.SetActive(showLevel);
|
|
}
|
|
|
|
if (showLevel && SkillLevelText != null)
|
|
{
|
|
SkillLevelText.text = level.ToString();
|
|
}
|
|
}
|
|
|
|
public void SetIcon(Sprite sprite)
|
|
{
|
|
if (SkillIcon != null)
|
|
{
|
|
SkillIcon.sprite = sprite;
|
|
}
|
|
}
|
|
|
|
public void SetColor(Color color)
|
|
{
|
|
if (SkillIcon != null)
|
|
{
|
|
SkillIcon.color = color;
|
|
}
|
|
}
|
|
}
|
|
}
|