备份CatanBuilding瘦身独立工程
This commit is contained in:
75
Assets/Scripts/EventBreak/EventBreakStashButtonFxCtrl.cs
Normal file
75
Assets/Scripts/EventBreak/EventBreakStashButtonFxCtrl.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using System;
|
||||
using asap.core;
|
||||
using Game;
|
||||
using DG.Tweening;
|
||||
|
||||
public class EventBreakStashButtonFxCtrl : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DeferredRewardStashButton rewardStashButton;
|
||||
[SerializeField] private GameObject rewardFly;
|
||||
[SerializeField] private float jiandaRewardShowDuration = 2.0f;
|
||||
private void Start()
|
||||
{
|
||||
EventBreakAct.EventAggregator.GetEvent<EventBreakBlockBreak>().Subscribe(OnBlockBreak).AddTo(this);
|
||||
}
|
||||
|
||||
private void OnBlockBreak(EventBreakBlockBreak e)
|
||||
{
|
||||
if (EventBreakAct.Ctx.IsItemGem(e.Item))
|
||||
return;
|
||||
MakeRewardFly(e);
|
||||
}
|
||||
private async void MakeRewardFly(EventBreakBlockBreak e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fly = Instantiate(rewardFly, transform).GetComponent<RewardItemNew>();
|
||||
fly.SetRewardPopupData(e.Item);
|
||||
fly.transform.position = e.BreakPos;
|
||||
fly.gameObject.SetActive(true);
|
||||
if (EventBreakAct.Ctx.IsItemFishCard(e.Item))
|
||||
{
|
||||
// Debug.Log($"[EventBreak] FishCard: From {rewardFly.transform.position} to {transform.position}");
|
||||
_ = PlayFishCardBundleAudio();
|
||||
fly.GetComponent<Animation>().Play("reward_common_open");
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardShowDuration));
|
||||
fly.GetComponent<Animation>().Play("reward_common_close");
|
||||
await System.Threading.Tasks.Task.Delay(24 * 1000 / 60);
|
||||
fly.GetComponent<CanvasGroup>().alpha = 1;
|
||||
await Awaiters.NextFrame;
|
||||
await DOTween.To(() => fly.transform.position,
|
||||
value => fly.transform.position = value, transform.position, 1.1f)
|
||||
.AsyncWaitForCompletion();
|
||||
rewardStashButton.PlayReceiveAnimationWithDelay(0f);
|
||||
EventBreakAct.EventAggregator.Publish(new EventBreakBlockInput(EEventBreakBlockInputOperation.Unblock));
|
||||
Destroy(fly.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
fly.GetComponent<Animation>().Play("reward_common_open");
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardShowDuration));
|
||||
fly.GetComponent<Animation>().Play("reward_common_close");
|
||||
await System.Threading.Tasks.Task.Delay(16 * 1000 / 60);
|
||||
rewardStashButton.PlayReceiveAnimationWithDelay(1f);
|
||||
await Awaiters.NextFrame;
|
||||
await fly.ParticleAttractor();
|
||||
// await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(1.1f));
|
||||
EventBreakAct.EventAggregator.Publish(new EventBreakBlockInput(EEventBreakBlockInputOperation.Unblock));
|
||||
Destroy(fly.gameObject);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Log($"[EventBreak] BreakBlockError: {ex.Message}\n{ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task PlayFishCardBundleAudio()
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_break_rewardfly"));
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(0.25f));
|
||||
GContext.Publish(new EventUISound("audio_ui_break_rewardget"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user