Example #1
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex == 1)
            {
                if (SettingsObject == null)
                {
                    var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();
                    volumeSettings.gameObject.SetActive(false);
                    SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                    SettingsObject.SetActive(false);
                    volumeSettings.gameObject.SetActive(true);
                    var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                    ReflectionUtil.CopyComponent(volume, typeof(SimpleSettingsController), typeof(SpeedSettingsController), SettingsObject);
                    Object.DestroyImmediate(volume);
                    SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                    Object.DontDestroyOnLoad(SettingsObject);
                }
            }
            else
            {
                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                }

                if (_mainGameSceneSetupData == null || scene.buildIndex != 4)
                {
                    return;
                }

                if (_lastLevelId != _mainGameSceneSetupData.levelId && !string.IsNullOrEmpty(_lastLevelId))
                {
                    TimeScale    = 1;
                    _lastLevelId = _mainGameSceneSetupData.levelId;
                }

                _lastLevelId = _mainGameSceneSetupData.levelId;

                _audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _audioTimeSync.forcedAudioSync = true;
                _songAudio = ReflectionUtil.GetPrivateField <AudioSource>(_audioTimeSync, "_audioSource");
                Enabled    = _mainGameSceneSetupData.gameplayOptions.noEnergy;
                var noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
                var noteCutSoundEffect        =
                    ReflectionUtil.GetPrivateField <NoteCutSoundEffect>(noteCutSoundEffectManager, "_noteCutSoundEffectPrefab");
                _noteCutAudioSource =
                    ReflectionUtil.GetPrivateField <AudioSource>(noteCutSoundEffect, "_audioSource");

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>().FirstOrDefault(x => x.name == "Buttons")
                             .transform.parent;
                canvas.gameObject.AddComponent <SpeedSettingsCreator>();
                TimeScale = TimeScale;

                gameSongController        = Resources.FindObjectsOfTypeAll <GameSongController>().FirstOrDefault();
                songObjectSpawnController = Resources.FindObjectsOfTypeAll <SongObjectSpawnController>().FirstOrDefault();
                scoreController           = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault <ScoreController>();

                scoresDict = new Dictionary <int, ScoreListItem>();
            }
        }
Example #2
0
        private void DeleteExistingNotes()
        {
            var _gameNotePrefab       = ReflectionUtil.GetPrivateField <NoteController>(songObjectSpawnController, "_gameNotePrefab");
            var _bombNotePrefab       = ReflectionUtil.GetPrivateField <BombNoteController>(songObjectSpawnController, "_bombNotePrefab");
            var _obstacleBottomPrefab = ReflectionUtil.GetPrivateField <ObstacleController>(songObjectSpawnController, "_obstacleBottomPrefab");
            var _obstacleTopPrefab    = ReflectionUtil.GetPrivateField <ObstacleController>(songObjectSpawnController, "_obstacleTopPrefab");

            // Same duration used in game
            float duration = 1.4f;
            List <NoteController> cubeNoteControllers = _gameNotePrefab.GetSpawned <NoteController>();

            foreach (NoteController noteController in cubeNoteControllers)
            {
                noteController.Dissolve(duration);
            }
            List <BombNoteController> bombNoteControllers = _bombNotePrefab.GetSpawned <BombNoteController>();

            foreach (BombNoteController bombNoteController in bombNoteControllers)
            {
                bombNoteController.Dissolve(duration);
            }
            List <ObstacleController> obstacleBottomControllers = _obstacleBottomPrefab.GetSpawned <ObstacleController>();

            foreach (ObstacleController obstacleController in obstacleBottomControllers)
            {
                obstacleController.Dissolve(duration);
            }
            List <ObstacleController> obstacleTopControllers = _obstacleTopPrefab.GetSpawned <ObstacleController>();

            foreach (ObstacleController obstacleController2 in obstacleTopControllers)
            {
                obstacleController2.Dissolve(duration);
            }
        }
Example #3
0
        public void OnUpdate()
        {
            if (Enabled)
            {
                // songTime is in seconds
                int currentBeat = (int)((_audioTimeSync.songTime / 60f) * gameSongController.beatsPerMinute);

                //Log("currentBeat:" + currentBeat + " songTime" + _audioTimeSync.songTime);
                if (currentBeat > previousBeat)
                {
                    previousBeat = currentBeat;
                    Log("currentBeat:" + currentBeat + " songTime:" + _audioTimeSync.songTime);

                    ScoreListItem scoreListItem = new ScoreListItem
                    {
                        baseScore  = ReflectionUtil.GetPrivateField <int>(scoreController, "_baseScore"),
                        multiplier = ReflectionUtil.GetPrivateField <int>(scoreController, "_multiplier"),
                        multiplierIncreaseProgress    = ReflectionUtil.GetPrivateField <int>(scoreController, "_multiplierIncreaseProgress"),
                        multiplierIncreaseMaxProgress = ReflectionUtil.GetPrivateField <int>(scoreController, "_multiplierIncreaseMaxProgress"),
                        combo    = ReflectionUtil.GetPrivateField <int>(scoreController, "_combo"),
                        maxCombo = ReflectionUtil.GetPrivateField <int>(scoreController, "_maxCombo"),
                        playerHeadWasInObstacle = ReflectionUtil.GetPrivateField <bool>(scoreController, "_playerHeadWasInObstacle"),
                        afterCutScoreBuffers    = ReflectionUtil.GetPrivateField <List <AfterCutScoreBuffer> >(scoreController, "_afterCutScoreBuffers")
                    };

                    // Add the data to the dictionary
                    scoresDict[currentBeat] = scoreListItem;
                }

                // Hack to ensure score is applied on rewind
                // prevFrameScore is applied on LateUpdate and the score will sometimes not be applied when rewinding.
                // This just applies the score again on the next frame to make sure that it changes.
                // May not be required
                if (applyScoreAgain)
                {
                    RewindScore(currentBeat);
                    applyScoreAgain = false;
                }
                else if (Input.GetKeyDown(KeyCode.R))
                {
                    // Trigger rewind here.
                    tmpBeat = currentBeat - rewindAmountBeats;
                    Rewind(tmpBeat < 0 ? 0 : tmpBeat);
                    applyScoreAgain = true;
                }
            }
        }
Example #4
0
        // Change the indexes for the next objects to hit, to account for the rewind
        private void WalkBackIndexes(float destinationTime)
        {
            // Move indexes back for all object arrays
            var _songObjectCallbackData = ReflectionUtil.GetPrivateField <List <SongController.SongObjectCallbackData> >(gameSongController, "_songObjectCallbackData");
            var _songData       = ReflectionUtil.GetPrivateField <SongData>(gameSongController, "_songData");
            var _nextEventIndex = ReflectionUtil.GetPrivateField <int>(gameSongController, "_nextEventIndex");

            float songTime = _audioTimeSync.songTime;

            for (int i = 0; i < _songObjectCallbackData.Count; i++)
            {
                SongController.SongObjectCallbackData songObjectCallbackData = _songObjectCallbackData[i];
                for (int j = 0; j < gameSongController.noteLinesCount; j++)
                {
                    // Loop backwards from the current "nextObjectIndexInLine"
                    // Break when we hit an object that is less than the current time, thus storing the next object that should be hit
                    while (songObjectCallbackData.nextObjectIndexInLine[j] > 0)
                    {
                        SongObjectData songObjectData = _songData.SongLinesData[j].songObjectsData[songObjectCallbackData.nextObjectIndexInLine[j]];
                        if (songObjectData.time < destinationTime)
                        {
                            break;
                        }
                        songObjectCallbackData.nextObjectIndexInLine[j]--;
                    }
                }
            }

            // Loop backwards from the current nextEventIndex.
            // Break when we hit an index that is less than the current time, thus storing the next event that should be played
            while (_nextEventIndex > 0)
            {
                SongEventData songEventData = _songData.SongEventData[_nextEventIndex];
                if (songEventData.time < destinationTime)
                {
                    break;
                }
                _nextEventIndex--;
            }
        }