58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Perk : MonoBehaviour
|
|
{
|
|
public Image bg;
|
|
public Image icon;
|
|
public GameObject lockIcon;
|
|
public TMP_Text text_level;
|
|
public TMP_Text text_lock;
|
|
public Transform kuang_duel;
|
|
public Transform tag_duel;
|
|
public TMP_Text perk_text_name;
|
|
public static string[] peak_bg = { "sp_rod_buff_white", "sp_rod_buff_blue", "sp_rod_buff_purple", "sp_rod_buff_yellow", "sp_rod_buff_yellow" };
|
|
|
|
private void Reset()
|
|
{
|
|
bg = transform.Find("bg").GetComponent<Image>();
|
|
icon = transform.Find("bg/icon").GetComponent<Image>();
|
|
text_level = transform.Find("bg/text_level").GetComponent<TMP_Text>();
|
|
text_lock = transform.Find("empty/text_lock").GetComponent<TMP_Text>();
|
|
lockIcon = transform.Find("empty").gameObject;
|
|
}
|
|
|
|
public void SetData(int id, int level, int quality)
|
|
{
|
|
text_level.gameObject.SetActive(level > 0);
|
|
lockIcon.SetActive(level == 0);
|
|
text_level.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", level);
|
|
RodAscendPerk data = GContext.container.Resolve<Tables>().TbRodAscendPerk.GetOrDefault(id);
|
|
if (data == null)
|
|
{
|
|
return;
|
|
}
|
|
string peakBgName = peak_bg[quality - 1];
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(bg, peakBgName, BasePanel.PanelName);
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(icon, data.Icon, BasePanel.PanelName);
|
|
kuang_duel = transform.Find("bg/kuang_duel");
|
|
tag_duel = transform.Find("bg/tag_duel");
|
|
if (kuang_duel != null)
|
|
{
|
|
kuang_duel.gameObject.SetActive(data.DuelPerk);
|
|
}
|
|
if (tag_duel != null)
|
|
{
|
|
tag_duel.gameObject.SetActive(data.DuelPerk);
|
|
}
|
|
if (perk_text_name != null)
|
|
{
|
|
perk_text_name.text = LocalizationMgr.GetText(data.Title_l10n_key);
|
|
}
|
|
}
|
|
}
|