using EnhancedUI.EnhancedScroller; using UnityEngine; using game; using asap.core; using System.Threading.Tasks; using UniRx; public class EventOfferJourneyWheelCellTop : EventOfferJourneyBlockView { [SerializeField] private GameObject fxLock, fxFirework; private EventOfferJourneyWheelAnimationParams _param; public override void Start() { base.Start(); GContext.OnEvent().Subscribe(OnRewardPanelClose).AddTo(this); } public void Init(EventOfferJourneyBlockData data, EState state, EnhancedScroller scroller, EventOfferJourneyWheelAnimationParams param, bool isGrandPrize = false) { base.Init(data, state, scroller, isGrandPrize); fxLock.SetActive(false); // fxReward.SetActive(true); fxFirework.SetActive(false); _param = param; } public async Task SetBought() { _state = EState.Bought; if (btnIap.gameObject.activeSelf) { btnIap.gameObject.SetActive(false); btnIapGray.gameObject.SetActive(false); } if (btnTicket.gameObject.activeSelf) { btnTicket.gameObject.SetActive(false); btnTicketGray.gameObject.SetActive(false); } // fxReward.SetActive(false); _ = PlayRewardDisappear(0.2f); if (goGrandReward != null) goGrandReward.SetActive(false); aniTick.gameObject.SetActive(true); GContext.Publish(new Game.EventUISound("audio_ui_offerjourneywheel_completed")); aniTick.Play("OfferJourneyWheelGet"); await PlayFx(fxFirework, _param.fireworkDelay); // _ = Task.Delay(TimeSpan.FromSeconds(aniTick.GetClip("OfferJourneyShellGet").length)); GContext.Publish(new EventOfferJourneyClosePanel()); var rawData = GContext.container.Resolve(); if (rawData is EventOfferJourneyLvlTriggerData lvlTriggerData && !lvlTriggerData.IsActive) { GContext.Publish(new EventOfferJourneyHideEntrance()); } // UnityEngine.Debug.Log($"Set Bought here @ {dataIndex}", this); } public async Task Unlock() { Debug.Log($"[EventOfferJourney] Top view unlock."); _state = EState.Active; goLock.SetActive(false); fxLock.SetActive(false); fxLock.SetActive(true); await Task.Delay(System.TimeSpan.FromSeconds(0.3f)); GContext.Publish(new Game.EventUISound("audio_ui_offerjourneyshell_break")); if (btnIapGray.gameObject.activeSelf) { btnIapGray.gameObject.SetActive(false); btnIap.gameObject.SetActive(true); } if (btnTicketGray.gameObject.activeSelf) { btnTicketGray.gameObject.SetActive(false); btnTicket.gameObject.SetActive(true); } GContext.Publish(new EventOfferJourneyDisplayEnd()); } public async void OnRewardPanelClose(RewardPanelClose _) { try { if (_state != EState.Active) return; await SetBought(); } catch (System.Exception e) { Debug.LogError(e); } } }