备份CatanBuilding瘦身独立工程
This commit is contained in:
98
Assets/Scripts/UI/BattlePass/BPRewardSlot.cs
Normal file
98
Assets/Scripts/UI/BattlePass/BPRewardSlot.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
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.NormalLevels.Add(_level);
|
||||
else
|
||||
eventData.VipLevels.Add(_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;
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnUnlockBpVip()
|
||||
{
|
||||
if (!_isNormal)
|
||||
{
|
||||
var particle = transform.Find("position/particle");
|
||||
go_vipLock?.SetActive(!_dataProvider.IsUnlockVip);
|
||||
particle.gameObject.SetActive(true);
|
||||
await new WaitForSeconds(2);
|
||||
|
||||
if (this != null)
|
||||
{
|
||||
particle.gameObject.SetActive(false);
|
||||
RefreshSlot();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_disposables?.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user