Esempio n. 1
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (AreSongsLoading)
            {
                //Scene changing while songs are loading. Since we are using a separate thread while loading, this is bad and could cause a crash.
                //So we have to stop loading.
                if (_loadingTask != null)
                {
                    _loadingTask.Cancel();
                    _loadingCancelled = true;
                    AreSongsLoading   = false;
                    LoadingProgress   = 0;
                    StopAllCoroutines();
                    _progressBar.ShowMessage("Loading cancelled\n<size=80%>Press Ctrl+R to refresh</size>");
                    Log("Loading was cancelled by player since they loaded another scene.");
                }
            }

            StartCoroutine(WaitRemoveScores());

            if (scene.buildIndex == 1)
            {
                _mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault();
                _mainFlowCoordinator.SetPrivateField("_levelCollectionsForGameplayModes", _customLevelCollectionsForGameplayModes);

                _standardLevelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault();
                if (_standardLevelDetailViewController == null)
                {
                    return;
                }
                _standardLevelDetailViewController.didPressPlayButtonEvent += StandardLevelDetailControllerOnDidPressPlayButtonEvent;

                var standardLevelListViewController = Resources.FindObjectsOfTypeAll <StandardLevelListViewController>().FirstOrDefault();
                if (standardLevelListViewController == null)
                {
                    return;
                }

                standardLevelListViewController.didSelectLevelEvent += StandardLevelListViewControllerOnDidSelectLevelEvent;
            }
            else if (scene.buildIndex == 5)
            {
                if (NoteHitVolumeChanger.PrefabFound)
                {
                    return;
                }
                var mainGameData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                if (mainGameData == null)
                {
                    return;
                }
                var level = mainGameData.difficultyLevel.level;
                var song  = CustomLevels.FirstOrDefault(x => x.levelID == level.levelID);
                if (song == null)
                {
                    return;
                }
                NoteHitVolumeChanger.SetVolume(song.customSongInfo.noteHitVolume, song.customSongInfo.noteMissVolume);
            }
        }
Esempio n. 2
0
        private void StandardLevelDetailControllerOnDidPressPlayButtonEvent(StandardLevelDetailViewController songDetailViewController)
        {
            if (!NoteHitVolumeChanger.PrefabFound)
            {
                return;
            }
            var level = songDetailViewController.difficultyLevel.level;
            var song  = CustomLevels.FirstOrDefault(x => x.levelID == level.levelID);

            if (song == null)
            {
                return;
            }
            NoteHitVolumeChanger.SetVolume(song.customSongInfo.noteHitVolume, song.customSongInfo.noteMissVolume);
        }
Esempio n. 3
0
        private void OnSceneTransitioned(Scene activeScene)
        {
            GameObject.Destroy(GameObject.Find("SongLoader Color Setter"));
            customSongColors    = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongColors", true, true);
            customSongPlatforms = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongPlatforms", true, true);
            if (AreSongsLoading)
            {
                //Scene changing while songs are loading. Since we are using a separate thread while loading, this is bad and could cause a crash.
                //So we have to stop loading.
                if (_loadingTask != null)
                {
                    _loadingTask.Cancel();
                    _loadingCancelled = true;
                    AreSongsLoading   = false;
                    LoadingProgress   = 0;
                    StopAllCoroutines();
                    _progressBar.ShowMessage("Loading cancelled\n<size=80%>Press Ctrl+R to refresh</size>");
                    Log("Loading was cancelled by player since they loaded another scene.");
                }
            }

            StartCoroutine(WaitRemoveScores());

            if (activeScene.name == MenuSceneName)
            {
                CurrentLevelPlaying = null;

                if (CustomLevelCollectionSO == null)
                {
                    var levelCollectionSO = Resources.FindObjectsOfTypeAll <LevelCollectionSO>().FirstOrDefault();
                    CustomLevelCollectionSO = CustomLevelCollectionSO.ReplaceOriginal(levelCollectionSO);
                }
                else
                {
                    CustomLevelCollectionSO.ReplaceReferences();
                }
                if (_standardLevelDetailViewController == null)
                {
                    _standardLevelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault();
                    if (_standardLevelDetailViewController == null)
                    {
                        return;
                    }
                    _standardLevelDetailViewController.didPressPlayButtonEvent += StandardLevelDetailControllerOnDidPressPlayButtonEvent;
                }

                if (_LevelListViewController == null)
                {
                    _LevelListViewController = Resources.FindObjectsOfTypeAll <LevelListViewController>().FirstOrDefault();
                    if (_LevelListViewController == null)
                    {
                        return;
                    }

                    _LevelListViewController.didSelectLevelEvent += StandardLevelListViewControllerOnDidSelectLevelEvent;
                }



                if (_characteristicViewController == null)
                {
                    _characteristicViewController = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSelectionViewController>().FirstOrDefault();
                    if (_characteristicViewController == null)
                    {
                        return;
                    }

                    _characteristicViewController.didSelectBeatmapCharacteristicEvent += OnDidSelectBeatmapCharacteristicEvent;
                }

                if (CustomPlatformsPresent)
                {
                    CheckForPreviousPlatform();
                }
            }
            else if (activeScene.name == GameSceneName)
            {
                _standardLevelSceneSetupData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault();
                if (_standardLevelSceneSetupData == null)
                {
                    return;
                }
                var level   = _standardLevelSceneSetupData.difficultyBeatmap;
                var beatmap = level as CustomLevel.CustomDifficultyBeatmap;
                if (beatmap != null)
                {
                    CurrentLevelPlaying = beatmap;

                    //The note jump movement speed now gets set in the Start method, so we're too early here. We have to wait a bit before overriding.
                    Invoke(nameof(DelayedNoteJumpMovementSpeedFix), 0.1f);
                }

                if (NoteHitVolumeChanger.PrefabFound)
                {
                    return;
                }
                var song = CustomLevels.FirstOrDefault(x => x.levelID == level.level.levelID);
                if (song == null)
                {
                    return;
                }
                NoteHitVolumeChanger.SetVolume(song.customSongInfo.noteHitVolume, song.customSongInfo.noteMissVolume);

                //Set environment if the song has customEnvironment
                if (CustomPlatformsPresent)
                {
                    CheckCustomSongEnvironment(song);
                }
                //Set enviroment colors for the song if it has song specific colors
                if (customSongColors)
                {
                    song.SetSongColors(CurrentLevelPlaying.colorLeft, CurrentLevelPlaying.colorRight, CurrentLevelPlaying.hasCustomColors);
                }
            }
        }