using asap.core; using GameCore; using TMPro; using UniRx; using UnityEngine; using UnityEngine.UI; public class BPRewardBar : PanelItemBase { #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(); NormalSlot = transform.Find("gift1").GetComponent(); VipSlot = transform.Find("gift2").GetComponent(); btn_buyLevel = transform.Find("btn_buygrade").GetComponent(); btn_buygrade = transform.parent.parent.Find("buygrade").GetComponent(); 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(); GContext.OnEvent().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); } public void OnUnlockBpVip() { VipSlot.OnUnlockBpVip(); } 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 }