备份CatanBuilding瘦身独立工程
This commit is contained in:
95
Assets/Scripts/UI/BattlePass/BPRewardBar.cs
Normal file
95
Assets/Scripts/UI/BattlePass/BPRewardBar.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BPRewardBar : PanelItemBase<int>
|
||||
{
|
||||
#region Field 乂
|
||||
private BPRewardSlot NormalSlot;
|
||||
private BPRewardSlot VipSlot;
|
||||
|
||||
private GameObject
|
||||
go_claim,
|
||||
go_unlock,
|
||||
go_normal;
|
||||
|
||||
private TMP_Text
|
||||
txt_level;
|
||||
Transform
|
||||
btn_buyLevel;
|
||||
Transform btn_buygrade;
|
||||
BattlePassDataProvider
|
||||
_dataProvider;
|
||||
#endregion
|
||||
bool isShowBuy;
|
||||
|
||||
#region Func
|
||||
private void Awake()
|
||||
{
|
||||
txt_level = transform.Find("grade/text_num").GetComponent<TMP_Text>();
|
||||
NormalSlot = transform.Find("gift1").GetComponent<BPRewardSlot>();
|
||||
VipSlot = transform.Find("gift2").GetComponent<BPRewardSlot>();
|
||||
btn_buyLevel = transform.Find("btn_buygrade").GetComponent<Transform>();
|
||||
btn_buygrade = transform.parent.parent.Find("buygrade").GetComponent<Transform>();
|
||||
go_claim = transform.Find("grade/position/claim").gameObject;
|
||||
go_unlock = transform.Find("grade/position/unlock").gameObject;
|
||||
go_normal = transform.Find("grade/position/bg").gameObject;
|
||||
|
||||
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
|
||||
GContext.OnEvent<BpGetExp>().Subscribe(x =>
|
||||
{
|
||||
|
||||
ChangeState();
|
||||
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
txt_level.text = data.ToString();
|
||||
ChangeState();
|
||||
NormalSlot.SetData(true, data);
|
||||
VipSlot.SetData(false, data);
|
||||
}
|
||||
|
||||
private void ChangeState()
|
||||
{
|
||||
go_claim.SetActive(false);
|
||||
go_normal.SetActive(false);
|
||||
go_unlock.SetActive(false);
|
||||
if (isShowBuy)
|
||||
{
|
||||
btn_buygrade?.gameObject.SetActive(false);
|
||||
}
|
||||
isShowBuy = data == _dataProvider.GetBPCurLevel && data != _dataProvider.BPMaxLevel;
|
||||
if (data == _dataProvider.GetBPCurLevel)
|
||||
{
|
||||
go_claim.SetActive(true);
|
||||
}
|
||||
else if (data > _dataProvider.GetBPCurLevel)
|
||||
{
|
||||
|
||||
go_unlock.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
go_normal.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (isShowBuy)
|
||||
{
|
||||
btn_buygrade?.gameObject.SetActive(true);
|
||||
btn_buygrade.position = btn_buyLevel.position;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user