using asap.core; using DG.Tweening; using UniRx; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Game; namespace game { public class EventScratchTicketStashButtonFxCtrl : MonoBehaviour { [SerializeField] private DeferredRewardStashButton rewardStashButton; [SerializeField] private GameObject rewardFly; [SerializeField] private float jiandaRewardShowDuration = 2.0f; private EventScratchTicketDataManager m_DataManager; private void Start() { m_DataManager = GContext.container.Resolve(); //EventBreakAct.EventAggregator.GetEvent().Subscribe(OnBlockBreak).AddTo(this); } private async void MakeRewardFly(EventBreakBlockBreak e) { try { var fly = Instantiate(rewardFly, transform).GetComponent(); 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().Play("reward_common_open"); await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardShowDuration)); fly.GetComponent().Play("reward_common_close"); await System.Threading.Tasks.Task.Delay(24 * 1000 / 60); fly.GetComponent().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().Play("reward_common_open"); await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardShowDuration)); fly.GetComponent().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")); } } }