93 lines
2.1 KiB
C#
93 lines
2.1 KiB
C#
using asap.core;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
|
|
public class BPRewardSlot : BPItemSlot
|
|
{
|
|
public enum ESlotState
|
|
{
|
|
LevelLock,
|
|
Normal,
|
|
CanGetReward,
|
|
HasGotReward
|
|
}
|
|
|
|
#region Field 乂
|
|
[SerializeField]
|
|
private GameObject
|
|
go_light;
|
|
#endregion
|
|
|
|
|
|
#region Func
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
btn_click?.OnClickAsObservable().Subscribe(_ => OnClickSlotToGetReward()).AddTo(_disposables);
|
|
|
|
GContext.OnEvent<GetAllBPRewards>().Subscribe(_ => OnGetAllRewards()).AddTo(_disposables);
|
|
GContext.OnEvent<BpGetExp>().Subscribe(_ => OnBuyBpLevel()).AddTo(_disposables);
|
|
//GContext.OnEvent<BpVipUnlock>().Subscribe(_ => OnUnlockBpVip()).AddTo(_disposables);
|
|
}
|
|
|
|
public void OnBuyBpLevel()
|
|
{
|
|
RefreshSlot();
|
|
}
|
|
|
|
|
|
public void OnGetAllRewards()
|
|
{
|
|
RefreshSlot();
|
|
}
|
|
public void OnClickSlotToGetReward()
|
|
{
|
|
if (btn_click)
|
|
btn_click.enabled = false;
|
|
var eventData = new GetBattlePassRewardEvent();
|
|
if (_isNormal)
|
|
eventData.NormalLevel = _level;
|
|
else
|
|
eventData.VipLevel = _level;
|
|
|
|
GContext.Publish(eventData);
|
|
|
|
// await RewardItem.ParticleAttractor();
|
|
ChangeState(ESlotState.HasGotReward);
|
|
}
|
|
public override void ChangeState(ESlotState state)
|
|
{
|
|
base.ChangeState(state);
|
|
go_light.SetActive(false);
|
|
switch (state)
|
|
{
|
|
case ESlotState.CanGetReward:
|
|
go_light.SetActive(true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void OnUnlockBpVip()
|
|
{
|
|
if (!_isNormal && _dataProvider.UILockVip)
|
|
{
|
|
var particle = transform.Find("position/particle");
|
|
particle.gameObject.SetActive(false);
|
|
go_vipLock?.SetActive(!_dataProvider.IsUnlockVip);
|
|
particle.gameObject.SetActive(true);
|
|
//RefreshSlot();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
{
|
|
_disposables?.Dispose();
|
|
}
|
|
#endregion
|
|
}
|
|
|