223 lines
8.3 KiB
C#
223 lines
8.3 KiB
C#
|
|
using asap.core;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
using System.Security.Claims;
|
|
public class MiniBattlePassCardPanel : MiniBattlePassFirstPanel
|
|
{
|
|
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;
|
|
Button btn_info;
|
|
GameObject overFlowLock;
|
|
GameObject overFlowUnlock;
|
|
TMP_Text exp_text_num;
|
|
Image exp_bar;
|
|
TMP_Text convert_text;
|
|
TMP_Text text_box_num;
|
|
Button reward_box;
|
|
Button available_box;
|
|
Button un_available_box;
|
|
int boxCount = 0;
|
|
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>();
|
|
btn_info = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/btn_info").GetComponent<Button>();
|
|
overFlowLock = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Lock").gameObject;
|
|
overFlowUnlock = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock").gameObject;
|
|
reward_box = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Lock/reward_box").GetComponent<Button>();
|
|
available_box = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock/transform/available_box").GetComponent<Button>();
|
|
un_available_box = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock/transform/un_available_box").GetComponent<Button>();
|
|
exp_text_num = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock/transform/bar/bg_bar/text_num").GetComponent<TMP_Text>();
|
|
exp_bar = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock/transform/bar/bg_bar/bar").GetComponent<Image>();
|
|
convert_text = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Unlock/transform/available_box/text_num").GetComponent<TMP_Text>();
|
|
text_box_num = transform.Find("root/ScrollView/Viewport/Content/panel_gift_final/money/position/Lock/reward_box/text_box_num").GetComponent<TMP_Text>();
|
|
timerFormat = "{0}";
|
|
}
|
|
protected override void Start()
|
|
{
|
|
if (miniBP.ItemShow[0] == 1001)
|
|
{
|
|
int showCount = 0;
|
|
var miniBPItemDatas = miniBP.miniBPItemDatas;
|
|
ItemData itemData;
|
|
for (int i = 0; i < miniBPItemDatas.Count; i++)
|
|
{
|
|
itemData = miniBPItemDatas[i].freeReward;
|
|
if (itemData.id == 1001)
|
|
{
|
|
showCount += itemData.count;
|
|
}
|
|
itemData = miniBPItemDatas[i].grandReward;
|
|
if (itemData.id == 1001)
|
|
{
|
|
showCount += itemData.count;
|
|
}
|
|
}
|
|
miniBP.ItemCountShow[0] = showCount;
|
|
}
|
|
base.Start();
|
|
|
|
var progressList = miniBP.ProgressList;
|
|
int nextlv = miniBP.rewardIndex + 1;
|
|
reward_box.onClick.AddListener(OnClickReward1);
|
|
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";
|
|
overFlowLock.SetActive(true);
|
|
overFlowUnlock.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
available_box.onClick.AddListener(ReceiveOverFlow);
|
|
un_available_box.onClick.AddListener(OnClickReward);
|
|
SetOverFlow();
|
|
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);
|
|
});
|
|
btn_info.onClick.AddListener(() =>
|
|
{
|
|
UIManager.Instance.ShowUI(new UIType("MiniBattlePass_FishcardInfoPopupPanel"));
|
|
});
|
|
text_content.text = LocalizationMgr.GetFormatTextValue(miniBP.TaskDesc, miniBP.Param);
|
|
text_buy.text = LocalizationMgr.GetFormatTextValue("UI_MiniBattlePass_FishcardPanel_2", text_buy.text);
|
|
}
|
|
|
|
protected override void ClickClaimAll()
|
|
{
|
|
miniBP.ReceiveAllReward();
|
|
if (miniBP.Data.IsVIP)
|
|
{
|
|
miniBP.ReceiveOverFlow();
|
|
}
|
|
RefreshPanel();
|
|
}
|
|
|
|
protected override void RefreshPanel()
|
|
{
|
|
SetOverFlow();
|
|
if (miniBP.IsVip)
|
|
{
|
|
bool isShowAllBtn = miniBP.Data.VRIndexs.Count <= miniBP.rewardIndex;
|
|
if (miniBP.FreeRewards.Count > 0)
|
|
{
|
|
isShowAllBtn |= miniBP.Data.NRIndexs.Count <= miniBP.rewardIndex;
|
|
}
|
|
isShowAllBtn |= boxCount > 0;
|
|
btn_claim.gameObject.SetActive(isShowAllBtn);
|
|
btn_claim_gray.gameObject.SetActive(!isShowAllBtn);
|
|
}
|
|
else
|
|
{
|
|
btn_claim_n.gameObject.SetActive(miniBP.Data.NRIndexs.Count <= miniBP.rewardIndex);
|
|
btn_claim_gray_n.gameObject.SetActive(miniBP.Data.NRIndexs.Count > miniBP.rewardIndex);
|
|
}
|
|
for (int i = 0; i < miniBattlePassItems.Count; i++)
|
|
{
|
|
miniBattlePassItems[i].Refresh();
|
|
}
|
|
}
|
|
void SetOverFlow()
|
|
{
|
|
boxCount = 0;
|
|
text_box_num.text = "";
|
|
var progressList = miniBP.ProgressList;
|
|
int nextlv = miniBP.rewardIndex + 1;
|
|
if (nextlv < progressList.Count)
|
|
return;
|
|
overFlowLock.SetActive(!miniBP.Data.IsVIP);
|
|
overFlowUnlock.SetActive(miniBP.Data.IsVIP);
|
|
|
|
var OverFlow = miniBP.OverFlow;
|
|
int exp = miniBP.Data.Exp - progressList[^1];
|
|
if (exp < 0)
|
|
{
|
|
exp = 0;
|
|
}
|
|
exp_text_num.text = $"{exp}/{OverFlow[0]}";
|
|
int count = exp / OverFlow[0] * OverFlow[1];
|
|
convert_text.text = $"X{count}";
|
|
exp_bar.fillAmount = exp / (float)OverFlow[0];
|
|
if (count > 0)
|
|
{
|
|
text_box_num.text = $"X{count}";
|
|
un_available_box.gameObject.SetActive(false);
|
|
available_box.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
text_box_num.text = "";
|
|
un_available_box.gameObject.SetActive(true);
|
|
available_box.gameObject.SetActive(false);
|
|
}
|
|
boxCount = count;
|
|
}
|
|
void OnClickReward1()
|
|
{
|
|
GContext.container.Resolve<PlayerItemData>().ShowItemTips(miniBP.OverFlow[2], reward_box.transform, GContext.container.Resolve<PlayerData>().InflationRate);
|
|
}
|
|
void OnClickReward()
|
|
{
|
|
GContext.container.Resolve<PlayerItemData>().ShowItemTips(miniBP.OverFlow[2], un_available_box.transform, GContext.container.Resolve<PlayerData>().InflationRate);
|
|
}
|
|
|
|
protected override void SetButtonShow()
|
|
{
|
|
buy.SetActive(!miniBP.IsVip);
|
|
claim.SetActive(miniBP.IsVip);
|
|
}
|
|
|
|
void ReceiveOverFlow()
|
|
{
|
|
if (!miniBP.Data.IsVIP)
|
|
{
|
|
return;
|
|
}
|
|
ItemData itemData = miniBP.ReceiveOverFlow();
|
|
if (itemData != null)
|
|
{
|
|
RefreshPanel();
|
|
}
|
|
else
|
|
OnClickReward();
|
|
}
|
|
}
|
|
|