Files
back_cantanBuilding/Assets/Scripts/MiniBP/UI/MiniBattlePassCardPanel.cs
2026-05-26 16:15:54 +08:00

93 lines
3.8 KiB
C#

using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class MiniBattlePassCardPanel : MiniBattlePassFirstPanel
{
protected override MiniBattlePassType Type => MiniBattlePassType.Fishcard;
protected override int showCount => 3;
Image bar;
TMP_Text text_num_bar;
TMP_Text text_num_level;
Button btn_questionmark;
GameObject info_tips;
Button btn_close_tips;
TMP_Text text_content;
TMP_Text exp_text_num;
TMP_Text source_text;
TMP_Text convert_text;
Image convert_icon;
protected override void Awake()
{
base.Awake();
bar = transform.Find("root/bar/bg_bar/bar").GetComponent<Image>();
text_num_bar = transform.Find("root/bar/bg_bar/text_num").GetComponent<TMP_Text>();
text_num_level = transform.Find("root/bar/level/text_num").GetComponent<TMP_Text>();
btn_questionmark = transform.Find("root/btn_questionmark").GetComponent<Button>();
info_tips = transform.Find("root/info_tips").gameObject;
btn_close_tips = info_tips.transform.Find("btn_close").GetComponent<Button>();
text_content = info_tips.transform.Find("item/text_content").GetComponent<TMP_Text>();
exp_text_num = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/money/text_num").GetComponent<TMP_Text>();
source_text = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/transform/icon_exp/text_num").GetComponent<TMP_Text>();
convert_text = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/transform/icon_money/text_num").GetComponent<TMP_Text>();
convert_icon = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/transform/icon_money").GetComponent<Image>();
timerFormat = "{0}";
}
protected override void Start()
{
base.Start();
if (miniBP.OverFlow.Count >= 3)
{
convert_text.text = miniBP.OverFlow[1].ToString();
source_text.text = miniBP.OverFlow[0].ToString();
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(miniBP.OverFlow[2]);
GContext.container.Resolve<IUIService>().SetImageSprite(convert_icon, item.Icon);
}
else
{
Debug.LogError("MiniBattlePassCardPanel: OverFlow count is less than 3, check the data.");
}
var progressList = miniBP.ProgressList;
int nextlv = miniBP.rewardIndex + 1;
if (nextlv < progressList.Count)
{
int startExp = 0;
if (nextlv > 0)
{
startExp = progressList[nextlv - 1];
}
int curExp = miniBP.Data.Exp - startExp;
int curMax = progressList[nextlv] - startExp;
text_num_bar.text = $"{curExp}/{curMax}";
bar.fillAmount = curExp / (float)curMax;
text_num_level.text = nextlv.ToString();
exp_text_num.text = "0";
}
else
{
exp_text_num.text = $"{miniBP.Data.Exp - progressList[^1]}";
bar.fillAmount = 1f;
text_num_bar.text = LocalizationMgr.GetText("UI_FishingRodPanel_Advanced_18");
text_num_level.text = miniBP.rewardIndex.ToString();
}
btn_questionmark.onClick.AddListener(() =>
{
info_tips.SetActive(true);
});
info_tips.SetActive(false);
btn_close_tips.onClick.AddListener(() =>
{
info_tips.SetActive(false);
});
text_content.text = LocalizationMgr.GetFormatTextValue(miniBP.TaskDesc, miniBP.Param);
text_buy.text = LocalizationMgr.GetFormatTextValue("UI_MiniBattlePass_FishcardPanel_2", text_buy.text);
}
}