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

56 lines
1.8 KiB
C#

using DG.Tweening;
using TMPro;
using UnityEngine.UI;
public class MiniBattlePassFirstPanel : MiniBattlePassPanel
{
TMP_Text text_num;
protected Button btn_claim_n;
protected Button btn_claim_gray_n;
protected override int showCount => 4;
protected override void Awake()
{
base.Awake();
text_num = transform.Find("root/total_prize/reward/text_num").GetComponent<TMP_Text>();
btn_claim_n = transform.Find("root/bottom/buy/btn_claim/btn_green").GetComponent<Button>();
btn_claim_gray_n = transform.Find("root/bottom/buy/btn_claim_gray/btn_green").GetComponent<Button>();
}
protected override void Start()
{
btn_claim_n.onClick.AddListener(ClickClaimAll);
text_num.text = $"x{ConvertTools.GetNumberString(miniBP.ItemCountShow[0])}";
base.Start();
}
protected override void RefreshPanel()
{
base.RefreshPanel();
if (!miniBP.IsVip)
{
btn_claim_n.gameObject.SetActive(miniBP.Data.NRIndexs.Count <= miniBP.rewardIndex);
btn_claim_gray_n.gameObject.SetActive(miniBP.Data.NRIndexs.Count > miniBP.rewardIndex);
}
}
protected override void JumpToIndex()
{
int index = miniBP.Data.showIndex;
float startPos = 1 - (index * 1f / (miniBPItemDatas.Count - showCount));
if (startPos > 1f) startPos = 1f;
if (startPos < 0f) startPos = 0f;
scrollRect.verticalNormalizedPosition = startPos;
if (miniBP.rewardIndex > index)
{
miniBP.SetOldLevel();
float endPos = 1 - (miniBP.rewardIndex * 1f / (miniBPItemDatas.Count - showCount));
if (endPos > 1f) endPos = 1f;
if (endPos < 0f) endPos = 0f;
scrollRect.DOVerticalNormalizedPos(endPos, 0.5f);
}
}
}