110 lines
2.7 KiB
C#
110 lines
2.7 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-04-25
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "BattlePassWindow" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
public partial class BattlePassWindow
|
|||
|
{
|
|||
|
public class RewardWidget : KUIWidget
|
|||
|
{
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
[KUIFlag]
|
|||
|
PropWidget __goAdProp;
|
|||
|
[KUIFlag]
|
|||
|
PropWidget __goFreeProp;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpLevel;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnAdStatus;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnFreeStatus;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _goStatus;
|
|||
|
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is BattlePassProxy.BattlePassLevelInfo info)
|
|||
|
{
|
|||
|
_tmpLevel.text = info.id.ToString();
|
|||
|
_goStatus.SetActive(!info.isUnlock);
|
|||
|
SetStatus(_btnFreeStatus.transform, info.freeStatus);
|
|||
|
SetStatus(_btnAdStatus.transform, info.adStatus);
|
|||
|
|
|||
|
var awards = info.item.adAwards;
|
|||
|
if (awards != null && awards.Length > 1)
|
|||
|
__goAdProp.SetCount(awards[0], awards[1]);
|
|||
|
|
|||
|
awards = info.item.freeAwards;
|
|||
|
if (awards != null && awards.Length > 1)
|
|||
|
__goFreeProp.SetCount(awards[0], awards[1]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SetStatus(Transform t, int status)
|
|||
|
{
|
|||
|
for (int i = 0; i < t.childCount; i++)
|
|||
|
{
|
|||
|
t.GetChild(i).gameObject.SetActive(i == status);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnFreeStatusBtnClick()
|
|||
|
{
|
|||
|
if (this.data is BattlePassProxy.BattlePassLevelInfo info)
|
|||
|
{
|
|||
|
if (info.freeStatus == 1)
|
|||
|
{
|
|||
|
BattlePassProxy.Instance.CollecReward(info.id, false, (error) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnAdStatusBtnClick()
|
|||
|
{
|
|||
|
if (this.data is BattlePassProxy.BattlePassLevelInfo info)
|
|||
|
{
|
|||
|
if (info.adStatus == 0)
|
|||
|
{
|
|||
|
ToastBox.ShowText("解锁侠客令后领取");
|
|||
|
}
|
|||
|
else if (info.adStatus == 1)
|
|||
|
{
|
|||
|
BattlePassProxy.Instance.CollecReward(info.id, true, (error) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_btnAdStatus.onClick.AddListener(this.OnAdStatusBtnClick);
|
|||
|
_btnFreeStatus.onClick.AddListener(this.OnFreeStatusBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|