98 lines
2.9 KiB
C#
98 lines
2.9 KiB
C#
|
|
using asap.core;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MiniBattlePassItemFishCard : MonoBehaviour, IMiniBattlePassItem
|
|
{
|
|
public GameObject tag_normal_mask;
|
|
public TMP_Text text_num_normal;
|
|
public GameObject tag_current;
|
|
public TMP_Text text_num_current;
|
|
public GameObject tag_first;
|
|
public RewardItemNew freeReward;
|
|
public GameObject freeClaim;
|
|
public Button freeClaimBtn;
|
|
public RewardItemNew grandReward;
|
|
public GameObject grandClaimLocked;
|
|
public GameObject fx_unlocked;
|
|
public GameObject grandClaim;
|
|
public Button grandClaimBtn;
|
|
protected MiniBattlePassDataModel miniBP;
|
|
protected bool isClaim;
|
|
MiniBPItemData data;
|
|
protected void Start()
|
|
{
|
|
grandClaimBtn.onClick.AddListener(ClickGrandClaim);
|
|
freeClaimBtn.onClick.AddListener(() =>
|
|
{
|
|
miniBP.ReceiveReward(data.index, true);
|
|
//Refresh();
|
|
GContext.Publish(new RefreshPanelEvent());
|
|
});
|
|
}
|
|
private void ClickLock()
|
|
{
|
|
if (isClaim)
|
|
{
|
|
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_106"));
|
|
}
|
|
}
|
|
|
|
public void Init(MiniBPItemData bpItemFirstData, MiniBattlePassDataModel miniBP)
|
|
{
|
|
if (bpItemFirstData == null)
|
|
{
|
|
return;
|
|
}
|
|
this.miniBP = miniBP;
|
|
this.data = bpItemFirstData;
|
|
isClaim = bpItemFirstData.progress >= bpItemFirstData.maxProgress;
|
|
|
|
grandReward.SetData(bpItemFirstData.grandReward);
|
|
//text_task.text = bpItemFirstData.taskName;
|
|
if (bpItemFirstData.freeReward != null)
|
|
{
|
|
freeReward.SetData(bpItemFirstData.freeReward);
|
|
}
|
|
tag_normal_mask.SetActive(!isClaim);
|
|
tag_first.SetActive(data.index == 0);
|
|
tag_current.SetActive(data.index == miniBP.rewardIndex);
|
|
text_num_current.text = text_num_normal.text = data.index.ToString();
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
grandClaimLocked.gameObject.SetActive(!data.isGrandReward);
|
|
grandClaim.SetActive(data.isGrandReward && !data.isGrandClaimed && isClaim);
|
|
grandClaimBtn.gameObject.SetActive(data.isGrandReward && !data.isGrandClaimed && isClaim);
|
|
freeClaim.SetActive(!data.isFreeClaimed && isClaim);
|
|
freeClaimBtn.gameObject.SetActive(!data.isFreeClaimed && isClaim);
|
|
grandReward.SetReceived(data.isGrandClaimed);
|
|
freeReward.SetReceived(data.isFreeClaimed);
|
|
}
|
|
public void UnlockRefresh()
|
|
{
|
|
fx_unlocked.SetActive(true);
|
|
}
|
|
private void ClickGrandClaim()
|
|
{
|
|
if (data.isGrandReward)
|
|
{
|
|
//领取付费奖励的逻辑
|
|
miniBP.ReceiveReward(data.index, false);
|
|
//Refresh();
|
|
GContext.Publish(new RefreshPanelEvent());
|
|
}
|
|
else
|
|
{
|
|
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_106"));
|
|
}
|
|
}
|
|
|
|
}
|
|
|