Example #1
0
        private void Awake()
        {
            _instance        = this;
            _spawnController = FindObjectOfType <SongObjectSpawnController>();

            if (_spawnController == null)
            {
                Console.WriteLine("Spawn controller was null");
                return;
            }

            // Get notes
            var gameNotePrefab = ReflectionUtil.GetPrivateField <NoteController>(_spawnController, "_gameNotePrefab");

            _notes = gameNotePrefab.GetSpawned <NoteController>();

            if (_notes.Count > 0)
            {
                Console.WriteLine("notes found");
            }
            else
            {
                Console.WriteLine("Notes not found");
                _notes = UnityEngine.Object.FindObjectsOfType <NoteController>().ToList();
                if (_notes.Count > 0)
                {
                    Console.WriteLine("Notes found with Object.FindObj");
                }
                else
                {
                    Console.WriteLine("Notes not found with Object.FindObj");
                }
            }
        }
Example #2
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>();
            }
        }