using UnityEngine; using System; using System.Threading.Tasks; using EnhancedUI.EnhancedScroller; using asap.core; using game; using UniRx; public class EventOfferJourneyScrollerCellShellRight : EventOfferJourneyBlockView { [SerializeField] private EventOfferJourneyShellPointPathView leftPoint, rightPoint; [SerializeField] private GameObject fxBubble, fxLock, fxReward; private EventOfferJourneyShellAnimationParams _param; public override void Start() { base.Start(); GContext.OnEvent().Subscribe(OnRewardPanelClose).AddTo(this); } public void Init(EventOfferJourneyBlockData data, EState state, EnhancedScroller scroller, EventOfferJourneyShellAnimationParams param, bool isGrandPrize = false) { base.Init(data, state, scroller, isGrandPrize); _param = param; rightPoint.Hide(); fxBubble.SetActive(false); fxLock.SetActive(false); fxReward.SetActive(true); if (isGrandPrize) { leftPoint.Hide(); return; } reward.transform.localScale = Vector3.one * param.rewardScale; leftPoint.Init(param.showDuration, param.gapDuration); switch (state) { case EState.Locked: leftPoint.SetDark(); break; case EState.Active: leftPoint.SetDark(); break; case EState.Bought: leftPoint.SetLight(); break; } } 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_offerjourneyshell_completed")); aniTick.Play("OfferJourneyShellGet"); await PlayFx(fxBubble, _param.bubbleDelay); // _ = Task.Delay(TimeSpan.FromSeconds(aniTick.GetClip("OfferJourneyShellGet").length)); if (dataIndex > 0) { await leftPoint.Play(); var nextViewRaw = _scroller.GetCellViewAtDataIndex(dataIndex - 1); if (nextViewRaw != null) { var nextView = nextViewRaw as EventOfferJourneyScrollerCellShellLeft; if (nextView != null) await nextView.Unlock(); } } else { 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($"Unlock here @ {dataIndex}", this); _state = EState.Active; goLock.SetActive(false); fxLock.SetActive(false); fxLock.SetActive(true); await Task.Delay(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 (Exception e) { Debug.LogError(e); } } }