using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Cute; using UnityEngine; using Wizard; using Wizard.Battle.Recovery; using Wizard.Scripts.Network.Data.TaskData.BuildDeckPurchase; using Wizard.Story; using Wizard.Story.ChapterSelection; using Wizard.Story.ChapterSelection.SelectionProcessing.Main; public class AreaSelectUI : UIBase { private enum CHAPTERUNLOCK_STATE { STATE_NULL, STATE_EFFECT_CLEARLABEL, STATE_FOCUS_NEWCHAPTER, STATE_DISP_MAPICON } private enum LoadStatusTutorialEffect { NotLoad, Loading, Loaded } private const float CLEAR_EFFECT_WAIT_SEC = 1.1f; private const float CLEAR_LABEL_DELAY_SEC = 0.4f; private const float NEWCHAPTER_FOCUS_SEC = 1f; private const float NEWCHAPTER_FOCUS_MAPICON_ENABLE_THRESHOLD = 0.55f; private const float MAPICON_EFFECTWAIT_SEC = 0.05f; private CHAPTERUNLOCK_STATE StateChapterUnlock; private float NewAreaTimer; private ChapterSelectButton _clearEffectPlayingChapter; private bool IsClearLabelDisplayed; private bool IsNewMapIconOpened; private bool IsNewMapIconFocused; private int nowAreaAllNum; private bool IsPlayingUnlockChapter; private GameObject _clearEffect; private GameObject _alreadyReadEffect; private List _loadEffectResources = new List(); public static readonly string CUESHEETNAME_MAP = "se_st_map"; public const int CHAPTERLIST_CAPACITY_DEFAULT = 8; private const int SORTINGORDER_EFFECT_OVER = 1; private const float PLAYERICON_Y = -320f; private const float TITLEPANEL_X_IN = 0f; private const float TITLEPANEL_X_OUT = 949f; private const float CHAPTERLIST_X_IN = -200f; private const float CHAPTERLIST_X_OUT = 400f; private const int CHAPTERLISTICON_MAX = 5; public const float CHAPTERLISTICON_OFFSET_Y = 80f; public const int CHAPTERLISTICON_MARGIN = 50; public const float CHAPTERLIST_SCROLL_RADIUS = 200f; public const float CHAPTERLIST_SWITCH_SEC = 0.5f; private static readonly Vector2 CHAPTERLIST_PANEL_CLIPOFFSET = new Vector2(0f, -420f); private static readonly Vector2 CHAPTERLIST_PANEL_CLIPPOS = new Vector2(0f, 0f); private static readonly Vector2 CHAPTERLIST_PANEL_CLIPSIZE = new Vector2(1200f, 80f); private static readonly string ANOTHER_ENDING_APPEARANCE_EFFECT_NAME = "scn_map_world_another_bright_1"; private string _beforeNextChapterId; private int? _beforeReleasedChapterNum; private int? _beforeReplayChapterIndex; [SerializeField] private GameObject PlayerIcon; [SerializeField] private GameObject _chapterRewardPanelRoot; private AreaSelInfo _chapterRewardPanel; [SerializeField] private GameObject _titlePanelRoot; private TitlePanelBase _titlePanel; [SerializeField] private GameObject RightPartsRoot; [SerializeField] private ChapterSelectButton _chapterSelectButtonOriginal; [SerializeField] private GameObject ChapterListRoot; [SerializeField] private UIScrollView ChapterListScrollView; [SerializeField] private SpringPanel ChapterListSpringPanel; private List _chapterSelectButtonList; private float ChapterListScrollYPrev; private GameObject ChapterListTapEffectLocator; private Effect ChapterListTapEffect; [SerializeField] private ChapterSelectSphere _chapterSelectSphere; private bool IsChapterSelectEnable = true; [SerializeField] private GameObject _chapterListScrollCollision; [SerializeField] private AreaSelectBG _BG = new AreaSelectBG(); [SerializeField] private AreaSelectMapIcon _mapIcon = new AreaSelectMapIcon(); private AreaSelectChapterEffect _chapterEffect = new AreaSelectChapterEffect(); [SerializeField] private GameObject _chapterEffectLocator; [SerializeField] private CommonPrefabContainer _commonPrefabContainer; [SerializeField] private float _chapterEffectSimulationSpeedAfterStop = 1f; private ScenarioSummary _scenarioSummary; private List _resourcePathList = new List(); private int _selectChapterIndex; private StoryChapterData _selectChapterData; private LoadStatusTutorialEffect _loadStatusTutorialEffect; private bool IsLoadEnd = true; private bool IsFadeInEnd; private bool IsSetupEnd; private TopBar _topBar; private bool IsUseChapterListScroll; private bool IsUseChapterListTapEffect; private bool IsUseChapterListSwitch; private bool _usedScrollWheel; private bool _isBackTransitionStarted; private IProcessing _firstSelectionProcessing; private StoryChapterData _anotherEndingAppearanceAnimationChapterData; private GameObject _anotherEndingAppearanceEffect; private bool _unlockAfterZoom; public static readonly Vector3 BG_SCALE_ZOOMOUT = new Vector3(0.28f, 0.28f, 0.28f); public static readonly Vector3 BG_POS_ZOOMOUT = new Vector3(-70f, -430f, 0f); public static readonly Vector3 BG_SCALE_ZOOMIN = new Vector3(0.6f, 0.6f, 0.6f); public const float BG_POS_ZOOMIN_OFFSET_Y = -400f; private const float CHAPTERLISTROOT_X_OUT = 800f; private const float CHAPTERLISTROOT_X_IN = -25f; private const float MAPMOVE_TIMER_IDLE = 1f; private const float MAPMOVE_TIMER_ZOOMIN = 1f; private const float MAPMOVE_TIMER_TOEND = 1f; private const float ANOTHER_ENDING_APPEARANCE_ANIMATION_TIME = 1.5f; [SerializeField] private iTween.EaseType BG_ZOOMIN_EASETYPE = iTween.EaseType.easeInOutCubic; private bool _isPlayingBGStartMove; private SelectedStoryInfo SelectedStoryInfo => Data.SelectedStoryInfo; private StorySectionData SectionData => SelectedStoryInfo.SectionData; private int SectionId => SectionData.Id; private int? SectionClassId => SelectedStoryInfo.SectionClassId; private List _chapterDataList => Data.StoryInfo.ChapterDataList; public bool IsUseChapterListClearedMask { get; private set; } private bool HasAnotherEndingAppearanceAnimation => _anotherEndingAppearanceAnimationChapterData != null; private void InitUnlockChapter() { ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_NULL); NewAreaTimer = 0f; SetPlayerIconVisible(isvisible: false); IsPlayingUnlockChapter = false; } private void LoadUnlockChapterResources(Action onFinish) { _loadEffectResources.Clear(); _loadEffectResources.Add(Toolbox.ResourcesManager.GetAssetTypePath("cmn_ui_clear_1", ResourcesManager.AssetLoadPathType.Effect2D)); _loadEffectResources.Add(Toolbox.ResourcesManager.GetAssetTypePath("cmn_ui_clear_2", ResourcesManager.AssetLoadPathType.Effect2D)); Toolbox.ResourcesManager.StartCoroutine_LoadAssetGroupAsync(_loadEffectResources, delegate { StartCoroutine(CreateEffect(onFinish)); }); } private IEnumerator CreateEffect(Action onFinish) { bool isLoadClearEffect = false; _clearEffect = EffectUtility.CreateEffect2D(new Effect2dCreateParam { Parent = base.gameObject, EffectName = "cmn_ui_clear_1", UnloadAssetList = _loadEffectResources, MaterialSetEndCallback = delegate { isLoadClearEffect = true; } }); bool isLoadAlreadyReadEffect = false; _alreadyReadEffect = EffectUtility.CreateEffect2D(new Effect2dCreateParam { Parent = base.gameObject, EffectName = "cmn_ui_clear_2", UnloadAssetList = _loadEffectResources, MaterialSetEndCallback = delegate { isLoadAlreadyReadEffect = true; } }); while (!isLoadClearEffect || !isLoadAlreadyReadEffect) { yield return null; } onFinish.Call(); } private void UnloadUnlockChapterResources() { Toolbox.ResourcesManager.RemoveAssetGroup(_loadEffectResources); _loadEffectResources.Clear(); } private void UpdateUnlockChapter() { switch (StateChapterUnlock) { case CHAPTERUNLOCK_STATE.STATE_EFFECT_CLEARLABEL: StateUnlockChapter_EffectClearLabel_Update(); break; case CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER: StateUnlockChapter_FocusNewChapter_Update(); break; case CHAPTERUNLOCK_STATE.STATE_DISP_MAPICON: StateUnlockChapter_DispMapIcon_Update(); break; } } private bool CheckUnlockChapter() { if (SectionData.IsTutorialCategory) { return false; } if (!_beforeReleasedChapterNum.HasValue || _beforeNextChapterId == null) { return false; } StoryChapterData storyChapterData = Data.StoryInfo.FindChapterData(_beforeNextChapterId); if (storyChapterData != null && storyChapterData.IsPlayedChapter) { return false; } int value = _beforeReleasedChapterNum.Value; return nowAreaAllNum > value; } private int? CheckSection20UnlockChapter() { if (SectionId == 20) { int num = nowAreaAllNum; bool flag = false; if (num == 10 && !PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_SECTION20_WERUSA_ANIMATION_PLAYED)) { flag = true; } if (num == 26 && !PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_SECTION20_NATERA_ANIMATION_PLAYED)) { flag = true; } if (flag) { return num - 2; } } return null; } private void SetupUnlockChapter() { SelectChapter(_beforeReleasedChapterNum.Value - 1, isplayse: false, iscalcscroll: true, ismapiconeffectenable: false); MoveToScreenChapterList(isIn: true, isImmediate: true); UpdateChapterList(isinterpscale: false); MoveToScreenTitlePanel(isIn: true, isImmediate: true); _chapterRewardPanel.MoveToScreen(isIn: true, isImmediate: true); _BG.GetBGRoot().transform.localScale = BG_SCALE_ZOOMIN; mapMoveTarget(0f); SetPlayerIconVisible(isvisible: false); _chapterSelectButtonList[_selectChapterIndex].SetClearVisible(visible: false); _topBar.SetBackButtonEnable(enable: false); _mapIcon.SetActiveMapIcon(nowAreaAllNum - 1, isActive: false); } private void StartUnlockChapter() { ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_EFFECT_CLEARLABEL); SetChapterScrollEnable(isEnable: false); IsPlayingUnlockChapter = true; } private void StartUnlockChapterWithoutClear() { ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER); SetChapterScrollEnable(isEnable: false); IsPlayingUnlockChapter = true; } private void OnUnlockChapterEnd() { SetPlayerIconVisible(_selectChapterData.IsDisplayMapIcon); SetChapterScrollEnable(isEnable: true); CheckPreBuildDeckConfirmDialog(); _topBar.SetBackButtonEnable(enable: true); IsPlayingUnlockChapter = false; } private void ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE newstate) { if (StateChapterUnlock != newstate) { switch (StateChapterUnlock) { case CHAPTERUNLOCK_STATE.STATE_EFFECT_CLEARLABEL: StateUnlockChapter_EffectClearLabel_Exit(); break; case CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER: StateUnlockChapter_FocusNewChapter_Exit(); break; case CHAPTERUNLOCK_STATE.STATE_DISP_MAPICON: StateUnlockChapter_DispMapIcon_Exit(); break; } switch (newstate) { case CHAPTERUNLOCK_STATE.STATE_EFFECT_CLEARLABEL: StateUnlockChapter_EffectClearLabel_Enter(); break; case CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER: StateUnlockChapter_FocusNewChapter_Enter(); break; case CHAPTERUNLOCK_STATE.STATE_DISP_MAPICON: StateUnlockChapter_DispMapIcon_Enter(); break; } StateChapterUnlock = newstate; } } private void StateUnlockChapter_EffectClearLabel_Update() { NewAreaTimer -= Time.deltaTime; float num = ((_BG.ChapterExtraData == null) ? 1.1f : (1.1f + _BG.ChapterExtraData.FirstClearEffectDelayTime)); if (!IsClearLabelDisplayed && NewAreaTimer < num - 0.4f) { _clearEffectPlayingChapter.OnFinishClearEffect(); IsClearLabelDisplayed = true; } if (NewAreaTimer < 0f && !IsNewMapIconFocused) { IsNewMapIconFocused = true; if (_BG.ChapterExtraData != null && _BG.ChapterExtraData.FirstClearMoveDelayTime > 0f) { _BG.SetExtraTexture(_BG.BeforeChapterId + 1); StartCoroutine(MoveDelay()); } else { ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER); } } } private IEnumerator MoveDelay() { yield return new WaitForSeconds((_BG.ChapterExtraData == null) ? 0f : _BG.ChapterExtraData.FirstClearMoveDelayTime); ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_FOCUS_NEWCHAPTER); } private void StateUnlockChapter_EffectClearLabel_Enter() { StartCoroutine(_BG.SetClearEffect()); if (_selectChapterIndex >= 0 && _selectChapterIndex < _chapterSelectButtonList.Count) { _clearEffectPlayingChapter = _chapterSelectButtonList[_selectChapterIndex]; _chapterSelectButtonList[_selectChapterIndex].UpdateClearState(_selectChapterData.ClearStatus); } if (!(null == _clearEffectPlayingChapter)) { _chapterSelectButtonList[_selectChapterIndex].OnStartClearEffect(); IsClearLabelDisplayed = false; GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_MAP_CLEAR); GameObject obj = ((_selectChapterData.ClearStatus == StoryChapterData.ChapterClearStatus.Cleared) ? _clearEffect : _alreadyReadEffect); obj.transform.parent = _clearEffectPlayingChapter.ClearLabelTransform; obj.transform.localPosition = Vector3.zero; obj.gameObject.SetActive(value: true); float newAreaTimer = ((_BG.ChapterExtraData == null) ? 1.1f : (1.1f + _BG.ChapterExtraData.FirstClearEffectDelayTime)); NewAreaTimer = newAreaTimer; } } private void StateUnlockChapter_EffectClearLabel_Exit() { _clearEffectPlayingChapter = null; } private void StateUnlockChapter_FocusNewChapter_Update() { mapMoveTarget((_BG.TransitionChapterExtraData == null) ? 1f : _BG.TransitionChapterExtraData.ChapterMoveTime); if (!IsNewMapIconOpened && NewAreaTimer < 0.55f) { if (!_selectChapterData.IsDisplayMapIcon) { _mapIcon.SetActiveMapIcon(_selectChapterIndex, isActive: false); } else { _mapIcon.SetActiveMapIcon(_selectChapterIndex, isActive: true); Vector3 mapIconPos = _mapIcon.GetMapIconPos(_selectChapterIndex, isLocal: false); GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_MAP_CHAPTER_1, mapIconPos.x, mapIconPos.y); GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_MAP_NEW_AREA_RELEASE); } IsNewMapIconOpened = true; } NewAreaTimer -= Time.deltaTime; if (NewAreaTimer < 0f) { ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_DISP_MAPICON); } } private void StateUnlockChapter_FocusNewChapter_Enter() { SelectChapter(nowAreaAllNum - 1, isplayse: false, iscalcscroll: true, ismapiconeffectenable: false, isFirstClear: true); GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_MAP_CAMERA_MOVE); NewAreaTimer = ((_BG.TransitionChapterExtraData == null) ? 1f : (1f + _BG.TransitionChapterExtraData.FirstClearMoveOutDelayTime)); IsNewMapIconOpened = false; } private void StateUnlockChapter_FocusNewChapter_Exit() { } private void StateUnlockChapter_DispMapIcon_Update() { NewAreaTimer -= Time.deltaTime; if (NewAreaTimer < 0f) { if (_selectChapterData.IsDisplayMapIcon) { _mapIcon.StartMapIconEffect(StoryChapterData.ChapterClearStatus.NotCleared, _selectChapterIndex); } ChangeStateUnlockChapter(CHAPTERUNLOCK_STATE.STATE_NULL); } } private void StateUnlockChapter_DispMapIcon_Enter() { NewAreaTimer = 0.05f; } private void StateUnlockChapter_DispMapIcon_Exit() { OnUnlockChapterEnd(); } public static void SetRecoveryData(SetupConditionInfo setupInfo) { Data.StoryInfo.IsPreBuildDeck = setupInfo.ScenarioDeckIsPreBuild; Data.StoryInfo.IsTrialDeck = setupInfo.ScenarioDeckIsTrial; Data.StoryInfo.IsStoryBattleDone = true; StoryNextSceneSelector.ResetHistoryOfUsingPreBuildDeck(); } public override void onFirstStart() { _chapterSelectButtonOriginal.gameObject.SetActive(value: false); bool flag = false; if (SectionData.IsTutorial) { IsUseChapterListScroll = false; IsUseChapterListClearedMask = true; IsUseChapterListTapEffect = true; IsUseChapterListSwitch = false; flag = false; } else if (SectionData.IsTutorialReplay) { IsUseChapterListScroll = true; IsUseChapterListClearedMask = false; IsUseChapterListTapEffect = false; IsUseChapterListSwitch = true; flag = true; } else { IsUseChapterListScroll = true; IsUseChapterListClearedMask = false; IsUseChapterListTapEffect = false; IsUseChapterListSwitch = true; flag = true; } UIManager.GetInstance().createInSceneLoading(); if (flag) { _topBar = StoryChapterSelectionUtility.CreateTopBar(base.gameObject, SelectedStoryInfo, new UIManager.ChangeViewSceneParam { OnChange = delegate { _isBackTransitionStarted = true; } }, 1); } _titlePanel = CreateTitlePanel(); _chapterRewardPanel = CreateChapterRewardPanel(); if (IsUseChapterListSwitch) { _chapterSelectSphere.OnClick = delegate { OnSwitchChapterSelect(); }; } StoryNextSceneSelector.ResetHistoryOfUsingPreBuildDeck(); Data.StoryInfo.IsStoryBattleDone = false; base.onFirstStart(); } protected override void onClose() { GameMgr.GetIns().GetEffectMgr().StopBuff(EffectMgr.EffectType.CMN_MAP_PLAYERICON, PlayerIcon); _mapIcon.Term(); _chapterEffect.UnLoadEffect(); _chapterEffect.Term(); StopEffectTap(); if (LoadStatusTutorialEffect.Loaded == _loadStatusTutorialEffect) { GameMgr.GetIns().GetEffectMgr().DisposeLatestMadeEffects(); _loadStatusTutorialEffect = LoadStatusTutorialEffect.NotLoad; } Toolbox.ResourcesManager.RemoveAssetGroup(_resourcePathList); _resourcePathList.Clear(); GameMgr.GetIns().GetSoundMgr().UnloadSe(CUESHEETNAME_MAP); UnloadUnlockChapterResources(); _BG.UnLoadBG(); _BG.Term(); if (_scenarioSummary != null) { _scenarioSummary.Dispose(); } _chapterRewardPanel.ReleaseClearPresent(); Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.CardListAssetPathList); Toolbox.ResourcesManager.CardListAssetPathList.Clear(); InitBGStartMove(); InitUnlockChapter(); base.onClose(); } private void OnTouchChapterListTutorial(int chapterindex) { if (chapterindex == _selectChapterIndex) { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE); StopEffectTap(); ExecuteSelectionProcessings(); } else if (SectionData.IsTutorialReplay) { SelectChapter(chapterindex, isplayse: true, iscalcscroll: true); } } private void SetChapterScrollEnable(bool isEnable) { if (null != ChapterListScrollView && ChapterListScrollView.enabled != isEnable) { ChapterListScrollView.enabled = isEnable; } if (_chapterSelectButtonList == null) { return; } foreach (ChapterSelectButton chapterSelectButton in _chapterSelectButtonList) { if (chapterSelectButton != null) { chapterSelectButton.SetScrollEnable(isEnable); } } } private void OnTouchChapterList(int chapterindex) { if (!IsPlayingUnlockChapter && !_unlockAfterZoom) { if (chapterindex == _selectChapterIndex) { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE); ExecuteSelectionProcessings(); } else { SelectChapter(chapterindex, isplayse: true, iscalcscroll: true); } } } private void OnCancelScenarioSummary() { if (IsUseChapterListTapEffect) { StartEffectTap(); } } private void StartEffectTap() { if (IsUseChapterListTapEffect && !(null != ChapterListTapEffect)) { ChapterListTapEffectLocator = _chapterSelectButtonList[_chapterSelectButtonList.Count - 1].TapEffectLocator; ChapterListTapEffect = GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_TUTORIAL_TAP_1, ChapterListTapEffectLocator); } } private void StopEffectTap() { if (!(null == ChapterListTapEffectLocator)) { GameMgr.GetIns().GetEffectMgr().StopBuff(EffectMgr.EffectType.CMN_TUTORIAL_TAP_1, ChapterListTapEffectLocator); ChapterListTapEffectLocator = null; ChapterListTapEffect = null; } } private void LimitAreaScroll() { int count = _chapterSelectButtonList.Count; UIPanel component = ChapterListScrollView.transform.GetComponent(); component.clipOffset = CHAPTERLIST_PANEL_CLIPOFFSET; component.baseClipRegion = new Vector4(CHAPTERLIST_PANEL_CLIPPOS.x, CHAPTERLIST_PANEL_CLIPPOS.y, CHAPTERLIST_PANEL_CLIPSIZE.x, CHAPTERLIST_PANEL_CLIPSIZE.y + (float)(count * 2) * 80f); } private void OnSwitchChapterSelect() { if (!IsPlayingUnlockChapter && !_isPlayingBGStartMove) { IsChapterSelectEnable = !IsChapterSelectEnable; SetChapterSelectEnable(IsChapterSelectEnable, isplayse: true); SetChapterScrollEnable(IsChapterSelectEnable); SetPlayerIconVisible(IsChapterSelectEnable && _selectChapterData.IsDisplayMapIcon); _BG.SetBGDragEnable(!IsChapterSelectEnable && _selectChapterData.IsEnableDragMapBG); if (IsChapterSelectEnable && _selectChapterData.IsDisplayMapIcon) { _mapIcon.StartMapIconEffect(_selectChapterData.ClearStatus, _selectChapterIndex); } else { _mapIcon.StopMapIconEffect(); } } } private void MoveToScreenObj(GameObject target, float localPosX, float time, Action onComplete = null) { if (Mathf.Approximately(time, 0f)) { Vector3 localPosition = target.transform.localPosition; localPosition.x = localPosX; target.transform.localPosition = localPosition; onComplete.Call(); return; } iTween.MoveTo(target, iTween.Hash("islocal", true, "x", localPosX, "time", time)); StartCoroutine(DelayedCall(time, onComplete.Call)); } private IEnumerator DelayedCall(float time, Action callback) { yield return new WaitForSeconds(time); if (!_isBackTransitionStarted) { callback.Call(); } } private void MoveToScreenRightPartsRoot(bool isIn, bool isImmediate) { float time = (isImmediate ? 0f : 0.5f); if (isIn) { SetChapterListMarqueeDisable(); } MoveToScreenObj(RightPartsRoot, isIn ? (-25f) : 800f, time, delegate { if (isIn) { SetSelectedChapterMarqueeEnable(); } }); if (isIn && !_unlockAfterZoom) { if (isImmediate) { SetChapterScrollEnable(IsUseChapterListScroll); } else { StartCoroutine(MoveToScreenRightCallBack(time)); } } } private IEnumerator MoveToScreenRightCallBack(float time) { yield return new WaitForSeconds(time); SetChapterScrollEnable(IsUseChapterListScroll); } private void MoveToScreenChapterList(bool isIn, bool isImmediate) { if (isIn) { SetChapterListMarqueeDisable(); } MoveToScreenObj(ChapterListRoot, isIn ? (-200f) : 400f, isImmediate ? 0f : 0.5f, delegate { if (isIn) { SetSelectedChapterMarqueeEnable(); } }); } private void MoveToScreenTitlePanel(bool isIn, bool isImmediate) { MoveToScreenObj(_titlePanel.gameObject, isIn ? 0f : 949f, isImmediate ? 0f : 0.5f); } private void SetChapterSelectEnable(bool enable, bool isplayse) { IsChapterSelectEnable = enable; _chapterSelectSphere.UpdateChapterSelectStatus(IsChapterSelectEnable, IsUseChapterListSwitch); MoveToScreenChapterList(enable, isImmediate: false); MoveToScreenTitlePanel(enable, isImmediate: false); _chapterRewardPanel.MoveToScreen(enable, isImmediate: false); _chapterListScrollCollision.SetActive(enable); _BG.SetBGDragEnable(!enable); if (isplayse) { GameMgr.GetIns().GetSoundMgr().PlaySe(enable ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF); } } private void SetChapterListMarqueeDisable() { if (_chapterSelectButtonList == null) { return; } foreach (ChapterSelectButton chapterSelectButton in _chapterSelectButtonList) { chapterSelectButton.SetMarqueeEnable(enable: false); } } private void SetSelectedChapterMarqueeEnable() { if (_chapterSelectButtonList != null) { _chapterSelectButtonList[_selectChapterIndex].SetMarqueeEnable(enable: true); } } protected override void onOpen() { base.onOpen(); UIManager.GetInstance().OpenNotTouch(); ResetSelectedStoryInfo(); InitBGStartMove(); InitUnlockChapter(); SetChapterSelectEnable(enable: true, isplayse: false); SetChapterScrollEnable(isEnable: false); _mapIcon.Init(); _BG.Init(this); _chapterEffect.Init(this, base.transform); SetPlayerIconVisible(isvisible: false); PlayerIcon.transform.localPosition = new Vector3(0f, -320f, 0f); _firstSelectionProcessing = CreateSelectionProcessings(SectionData.IsTutorialCategory); StartCoroutine(Setup()); } private IEnumerator Setup() { IsSetupEnd = false; if (SectionData.IsTutorialCategory) { SetupChapterDataListTutorial(); } else { yield return StoryChapterSelectionUtility.StoryInfoTaskCoroutine(SelectedStoryInfo); yield return StoryChapterSelectionUtility.LoadAiMasterCoroutine(_chapterDataList); StoryChapterSelectionUtility.RegisterMaintenanceChapters(_chapterDataList); _anotherEndingAppearanceAnimationChapterData = ((_beforeNextChapterId == null) ? _chapterDataList.FirstOrDefault((StoryChapterData x) => x.IsPlayAnotherEndingAppearanceAnimation && x.IsReleased) : null); } StartCoroutine(assetSetting()); IsLoadEnd = false; StartCoroutine(LoadAndSetupResourcesAsync()); _BG.LoadBG(SectionData, SectionClassId); _chapterEffect.LoadEffect(_chapterDataList); _chapterRewardPanel.LoadClearPresent(_chapterDataList); while (!IsLoadEnd || !_chapterRewardPanel.GetLoadEnd() || !_BG.GetLoadEnd() || !_chapterEffect.GetLoadEnd()) { yield return null; } SetupChapterList(); _mapIcon.SetupMapIcon(_chapterDataList); if (CheckUnlockChapter()) { SetupUnlockChapter(); } else { int? focus = CheckSection20UnlockChapter(); if (focus.HasValue) { _unlockAfterZoom = true; } SetupBGStartMove(focus); } _chapterRewardPanel.SetClearPresent(_selectChapterData); _BG.SetActiveBGEffect(isActive: true); IsFadeInEnd = false; UIManager.GetInstance().OnReadyViewScene(isFadein: true, null, OnFadeInEnd); _BG.SetupEnd(); IsSetupEnd = true; } private IEnumerator LoadAndSetupResourcesAsync() { _resourcePathList.Clear(); foreach (StoryChapterData chapterData in _chapterDataList) { _resourcePathList.Add(ChapterSelectButton.GetHeaderPath(chapterData, isFetch: false)); } if (IsUseChapterListTapEffect) { _loadStatusTutorialEffect = LoadStatusTutorialEffect.Loading; GameMgr.GetIns().GetEffectMgr().InitCommonEffect("Json/EffectTutorialData", isBattle: false, isField: false, isBattleEffect: false, delegate { _loadStatusTutorialEffect = LoadStatusTutorialEffect.Loaded; }); } GameMgr.GetIns().GetSoundMgr().LoadSe(CUESHEETNAME_MAP); _scenarioSummary = new ScenarioSummary(SectionId, SectionClassId); yield return StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(_resourcePathList, null)); bool isLoadedClearEffect = false; LoadUnlockChapterResources(delegate { isLoadedClearEffect = true; }); while (!_scenarioSummary.IsValid || LoadStatusTutorialEffect.Loading == _loadStatusTutorialEffect || !isLoadedClearEffect || !_titlePanel.IsFinishInit) { yield return null; } if (HasAnotherEndingAppearanceAnimation) { yield return EffectMgr.LoadAndInstantiate2dEffectCoroutine(ANOTHER_ENDING_APPEARANCE_EFFECT_NAME, delegate(GameObject createdEffect, List loadedAssets) { _anotherEndingAppearanceEffect = createdEffect; createdEffect.transform.parent = base.transform; _resourcePathList.AddRange(loadedAssets); }); } IsLoadEnd = true; } public override void onMove() { if (!IsSetupEnd || !IsFadeInEnd) { SetChapterListMarqueeDisable(); return; } if (IsPlayingUnlockChapter) { UpdateUnlockChapter(); UpdateChapterList(); return; } UpdateChapterList(); if (_isPlayingBGStartMove) { return; } if (_unlockAfterZoom) { _unlockAfterZoom = false; StartUnlockChapterWithoutClear(); return; } UpdateTamaArrow(); if (_BG.IsBGDragEnable()) { _BG.UpdateBGDrag(); } else { mapMoveTarget((_BG.TransitionChapterExtraData == null) ? 1.5f : _BG.TransitionChapterExtraData.ChapterMoveTime); } _mapIcon.UpdateMapIconEffectPos(_selectChapterIndex); float y = ChapterListScrollView.transform.localPosition.y; int num = (450 - (int)y) / 80; if (num < 0) { num = 0; } else if (num >= _chapterSelectButtonList.Count) { num = _chapterSelectButtonList.Count - 1; } if (num != _selectChapterIndex) { SelectChapter(num, isplayse: true); } base.onMove(); } private void SelectChapter(int newIndex, bool isplayse = false, bool iscalcscroll = false, bool ismapiconeffectenable = true, bool isFirstClear = false) { int selectChapterIndex = _selectChapterIndex; _selectChapterIndex = newIndex; if (_selectChapterIndex < 0 || _selectChapterIndex >= _chapterDataList.Count) { _selectChapterIndex = 0; } if (SectionId == 20) { if (_selectChapterIndex == 9) { PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.IS_SECTION20_WERUSA_ANIMATION_PLAYED, flag: true); } else if (_selectChapterIndex == 25) { PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.IS_SECTION20_NATERA_ANIMATION_PLAYED, flag: true); } } string chapterId = (newIndex + 1).ToString(); _selectChapterData = _chapterDataList.Single((StoryChapterData x) => x.ChapterId == chapterId); _BG.OnChangeSelectChapter(_selectChapterData, isFirstClear); if (SectionId == 20) { int chapterId2 = int.Parse(_selectChapterData.ChapterId); List chaptersWithDifferentBackgroundFrom = _BG.GetChaptersWithDifferentBackgroundFrom(chapterId2); for (int num = 0; num < _chapterSelectButtonList.Count; num++) { bool isActive = !chaptersWithDifferentBackgroundFrom.Contains(num + 1); _mapIcon.SetActiveMapIcon(num, isActive); } } _mapIcon.StopMapIconEffect(); if (ismapiconeffectenable && _selectChapterData.IsDisplayMapIcon) { _mapIcon.StartMapIconEffect(_selectChapterData.ClearStatus, _selectChapterIndex); } SetPlayerIconVisible(_selectChapterData.IsDisplayMapIcon); SwitchChapterEffectVisible(selectChapterIndex); _chapterRewardPanel.SetClearPresent(_selectChapterData); if (isplayse) { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_SCROLL); } if (iscalcscroll) { float num2 = 400f - (float)_selectChapterIndex * 80f; Vector3 position = ChapterListScrollView.transform.position; position.y = num2; ChapterListScrollView.transform.localPosition = position; ChapterListScrollView.GetComponent().clipOffset = new Vector2(0f, 0f - num2); if (null == ChapterListSpringPanel) { ChapterListSpringPanel = ChapterListScrollView.GetComponent(); } if (null != ChapterListSpringPanel) { ChapterListSpringPanel.target = Vector3.zero; ChapterListSpringPanel.strength = 0f; ChapterListSpringPanel.onFinished = null; ChapterListSpringPanel.enabled = false; } } _chapterSelectSphere.IsScrollUpEnable = IsUseChapterListScroll && _chapterSelectButtonList.Count > 1 && _selectChapterIndex < _chapterSelectButtonList.Count - 1; _chapterSelectSphere.IsScrollDownEnable = IsUseChapterListScroll && _chapterSelectButtonList.Count > 1 && _selectChapterIndex > 0; _chapterSelectSphere.OnSelectChapter(IsChapterSelectEnable); } private void UpdateTamaArrow() { if (IsChapterSelectEnable) { _chapterSelectSphere.UpdateArrowAlpha(); } } private void UpdateChapterList(bool isinterpscale = true) { for (int i = 0; i < _chapterSelectButtonList.Count; i++) { ChapterSelectButton chapterSelectButton = _chapterSelectButtonList[i]; if (chapterSelectButton != null) { chapterSelectButton.UpdateSelectStatus(_selectChapterIndex, i, this, isinterpscale, ChapterListScrollView); } } if (_isPlayingBGStartMove) { return; } bool flag = false; float y = ChapterListScrollView.transform.localPosition.y; if (ChapterListScrollYPrev != y) { ChapterListScrollYPrev = y; y = 450 - (int)y; flag = !Input.GetMouseButton(0) && Input.mouseScrollDelta.y < 0f; if (Input.GetMouseButton(0) || flag) { _chapterSelectSphere.UpdateRotationOnScroll(y, _chapterSelectButtonList.Count); } } if (Input.GetMouseButtonUp(0) || (!flag && _usedScrollWheel)) { _chapterSelectSphere.ResetRotationOnScroll(); } _usedScrollWheel = flag; } private void OnFadeInEnd() { UIManager.GetInstance().offNotTouch(); if (CheckUnlockChapter()) { StartUnlockChapter(); } else { StartBGStartMove(); CheckPreBuildDeckConfirmDialog(); } IsFadeInEnd = true; } public static void CheckPreBuildDeckConfirmDialog() { } private static void ShowBuildDeckBuyConfirmDialog(int currentCount, int maxCount) { int productId = PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.LAST_BATTLE_DECK_ID); if (currentCount < maxCount) { SystemText systemText = Data.SystemText; string message = systemText.Get("Story_0057"); if (currentCount > 0) { message = systemText.Get("Story_0058"); } DialogBase dialogBase = UIManager.GetInstance().CreateConfirmationDialog(message); dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn); dialogBase.SetTitleLabel(systemText.Get("Story_0056")); dialogBase.SetButtonText(systemText.Get("Shop_0095"), systemText.Get("Common_0005")); dialogBase.onPushButton1 = delegate { BuildDeckPurchasePage.BuildDeckConfirmDialogShow(productId); UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.BuildDeckPurchasePage); UIManager.GetInstance()._Footer.UpdateCurrentIndex(5); }; } } private void SetupChapterDataListTutorial() { Data.StoryInfo.ChapterDataList = Data.Master.TutorialAreaSelectList.Select((TutorialAreaSelect x) => new StoryChapterData(x)).ToList(); } private void SetupChapterList() { if (_chapterDataList == null) { return; } if (_chapterSelectButtonList != null) { for (int i = 0; i < _chapterSelectButtonList.Count; i++) { UnityEngine.Object.Destroy(_chapterSelectButtonList[i].gameObject); } } _chapterSelectButtonList = new List(8); nowAreaAllNum = 0; for (int j = 0; j < _chapterDataList.Count; j++) { if (!_chapterDataList[j].IsReleased) { continue; } ChapterSelectButton chapterSelectButton = UnityEngine.Object.Instantiate(_chapterSelectButtonOriginal); chapterSelectButton.gameObject.SetActive(value: true); chapterSelectButton.transform.parent = ChapterListScrollView.transform; chapterSelectButton.transform.localPosition = new Vector3(0f, -400f + (float)j * 80f, 0f); chapterSelectButton.transform.localScale = Vector3.one; chapterSelectButton.name = "chapterlist_" + j.ToString("00"); chapterSelectButton.SetChapterData(_chapterDataList[j], this, ChapterListScrollView); int index = j; chapterSelectButton.OnClick = delegate { if (SectionData.IsTutorialCategory) { OnTouchChapterListTutorial(index); } else { OnTouchChapterList(index); } }; _chapterSelectButtonList.Add(chapterSelectButton); nowAreaAllNum++; } LimitAreaScroll(); ChapterListScrollView.ResetPosition(); } private void mapMoveTarget(float time) { Vector3 mapIconPos = _mapIcon.GetMapIconPos(_selectChapterIndex, isLocal: true); iTween.MoveUpdate(_BG.GetBGRoot(), iTween.Hash("islocal", true, "x", BG_SCALE_ZOOMIN.x * (mapIconPos.x * -1f), "y", BG_SCALE_ZOOMIN.y * (mapIconPos.y * -1f) + -400f, "time", time, "easetype", iTween.EaseType.easeOutExpo)); } private void SetPlayerIconVisible(bool isvisible) { if (isvisible) { GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_MAP_PLAYERICON, PlayerIcon); } else { GameMgr.GetIns().GetEffectMgr().StopBuff(EffectMgr.EffectType.CMN_MAP_PLAYERICON, PlayerIcon); } } private void SwitchChapterEffectVisible(int previousChapter) { if (!(_chapterEffect.GetPlayingEffect() == _selectChapterData.ChapterEffectPath)) { float? simulationSpeedAfterStop = null; if (SectionId == 20 && AreaBGInfoSection20.IsSpeedUpParticleTransition(previousChapter, _selectChapterIndex)) { simulationSpeedAfterStop = _chapterEffectSimulationSpeedAfterStop; } _chapterEffect.StopEffect(simulationSpeedAfterStop); _chapterEffect.PlayEffect(_selectChapterData.ChapterEffectPath, _chapterEffectLocator.transform.localPosition); } } public string GetChapterTitleStory(string chapterID) { if (_scenarioSummary == null) { return ""; } return _scenarioSummary.GetData(chapterID).Title; } private TitlePanelBase CreateTitlePanel() { return StoryChapterSelectionUtility.CreateTitlePanel(_titlePanelRoot, _commonPrefabContainer.CharaInfoPanelPrefab, _commonPrefabContainer.SectionInfoPanelPrefab, SelectedStoryInfo); } private AreaSelInfo CreateChapterRewardPanel() { return StoryChapterSelectionUtility.CreateChapterRewardPanel(_chapterRewardPanelRoot, _commonPrefabContainer.ChapterRewardPanelPrefab); } private void ResetSelectedStoryInfo() { _beforeNextChapterId = SelectedStoryInfo.NextChapterId; _beforeReleasedChapterNum = SelectedStoryInfo.ReleasedChapterNum; _beforeReplayChapterIndex = SelectedStoryInfo.ReplayChapterIndex; SelectedStoryInfo.ClearInfoForChapterSelectionScene(); } private static IProcessing CreateSelectionProcessings(bool isTutorialCategory) { IProcessing[] array = ((!isTutorialCategory) ? new IProcessing[8] { new SubChapterSelectionDialogDisplay(), new SummaryDialogDisplay(), new DeckSelectionDialogDisplay(), new ChapterCharaDecider(), new DownloadInfoGetter(), new DownloadConfirmDialogDisplay(), new DeckSelectionConfirmDialogDisplay(), new StoryStarter() } : new IProcessing[3] { new SummaryDialogDisplay(), new ChapterCharaDecider(), new TutorialStoryStarter() }); for (int i = 0; i < array.Length - 1; i++) { array[i].NextProcessing = array[i + 1]; } return array.FirstOrDefault(); } private void ExecuteSelectionProcessings() { if (_firstSelectionProcessing != null) { Parameter param = CreateSelectionProcessingParameter(); _firstSelectionProcessing.Execute(param); } } private Parameter CreateSelectionProcessingParameter() { return new Parameter(this, _commonPrefabContainer, _scenarioSummary, SelectedStoryInfo, _selectChapterData, nowAreaAllNum, null, _selectChapterData.IsPlayedChapter ? new int?(_selectChapterIndex) : ((int?)null)); } private void InitBGStartMove() { iTween.Stop(_BG.GetBGRoot()); } private void SetupBGStartMove(int? focus) { int newIndex = (focus.HasValue ? focus.Value : GetStartFocusChapterIndex()); SelectChapter(newIndex, isplayse: false, iscalcscroll: true, ismapiconeffectenable: false); MoveToScreenRightPartsRoot(isIn: false, isImmediate: true); _chapterRewardPanel.MoveToScreen(isIn: false, isImmediate: true); if (AspectCamera.SafeAreaRate < 1f) { float num = (float)Screen.width / (float)Screen.height / 1.7777778f; _BG.GetBGRoot().transform.localScale = BG_SCALE_ZOOMOUT * num; } else { _BG.GetBGRoot().transform.localScale = BG_SCALE_ZOOMOUT; } _BG.GetBGRoot().transform.localPosition = BG_POS_ZOOMOUT; SetPlayerIconVisible(isvisible: false); InitAnotherEndingAppearanceEffect(); } private void StartBGStartMove() { StartCoroutine(PlayAnimationCoroutine()); } private IEnumerator PlayAnimationCoroutine() { _isPlayingBGStartMove = true; yield return new WaitForSeconds(1f); yield return ZoomInCoroutine(); if (HasAnotherEndingAppearanceAnimation) { yield return PlayAnotherEndingAppearanceAnimationCoroutine(); } yield return PlayUiEntranceAnimationCoroutine(); _isPlayingBGStartMove = false; } private IEnumerator ZoomInCoroutine() { iTween.ScaleTo(_BG.GetBGRoot(), iTween.Hash("scale", BG_SCALE_ZOOMIN, "islocal", true, "time", 1f, "easetype", BG_ZOOMIN_EASETYPE)); Vector3 mapIconPos = _mapIcon.GetMapIconPos(_selectChapterIndex, isLocal: true); iTween.MoveTo(_BG.GetBGRoot(), iTween.Hash("islocal", true, "x", BG_SCALE_ZOOMIN.x * (mapIconPos.x * -1f), "y", BG_SCALE_ZOOMIN.y * (mapIconPos.y * -1f) + -400f, "time", 1f, "easetype", BG_ZOOMIN_EASETYPE)); yield return new WaitForSeconds(1f); } private IEnumerator PlayAnotherEndingAppearanceAnimationCoroutine() { _anotherEndingAppearanceEffect.SetActive(value: true); yield return new WaitForSeconds(1.5f); } private IEnumerator PlayUiEntranceAnimationCoroutine() { SetPlayerIconVisible(_selectChapterData.IsDisplayMapIcon); if (_selectChapterData.IsDisplayMapIcon) { _mapIcon.StartMapIconEffect(_selectChapterData.ClearStatus, _selectChapterIndex); } StartCoroutine(assetSetting()); MoveToScreenRightPartsRoot(isIn: true, isImmediate: false); MoveToScreenTitlePanel(isIn: true, isImmediate: false); _chapterRewardPanel.MoveToScreen(isIn: true, isImmediate: false); yield return new WaitForSeconds(1f); StartEffectTap(); } private int GetStartFocusChapterIndex() { if (HasAnotherEndingAppearanceAnimation) { return int.Parse(_anotherEndingAppearanceAnimationChapterData.ChapterId) - 1; } if (_beforeReplayChapterIndex.HasValue && _beforeReplayChapterIndex.Value < nowAreaAllNum - 1) { return _beforeReplayChapterIndex.Value + 1; } return nowAreaAllNum - 1; } private void InitAnotherEndingAppearanceEffect() { if (HasAnotherEndingAppearanceAnimation) { int chapterIndex = int.Parse(_anotherEndingAppearanceAnimationChapterData.ChapterId) - 1; InitEffect(_anotherEndingAppearanceEffect, _mapIcon.GetMapIconObject(chapterIndex)); } } private static void InitEffect(GameObject effect, GameObject parent) { Transform transform = effect.transform; Vector3 localScale = UIManager.GetInstance().UIManagerRoot.transform.localScale; transform.parent = parent.transform; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = new Vector3(1f / localScale.x, 1f / localScale.y, 1f / localScale.z); UIManager.GetInstance().SetLayerRecursive(transform, parent.layer); } }