void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { // Shuffle Obstacle Scenes, except "Limbo Scene" if (!levelName.Equals("Limbo Scene")) { if (StateSaver.shuffledObstacleQueue.Count > 0) { string nextSceneName = StateSaver.shuffledObstacleQueue.Dequeue(); levelName = Utilities.ObstacleToSceneName(nextSceneName); // Debug.Log("Converted '" + nextSceneName + "' to '" + levelName + "'."); } else { Debug.Log("The length of the shuffledObstacleQueue is 0. Shuffling..."); StateSaver.RescrambleObstacles(); } } // TODO: Check if the loaded scene is a valid scene by using the following command: // SceneManager.GetSceneByName(levelName).IsValid() savedState.ui.dontDestroyOnLoad(); savedState.dontDestroyOnLoad(); savedState.playerHandler.dontDestroyOnLoad(); SceneManager.LoadScene(levelName, LoadSceneMode.Single); } }
float lerpTime = 0; // lerp control variable void Start() { colorDictionary = GenericReader.GetBackgroundColorDictionary(); // Next scene string nextScene = String.Empty; if (StateSaver.shuffledObstacleQueue.Count <= 0) { StateSaver.RescrambleObstacles(); } nextScene = StateSaver.shuffledObstacleQueue.Peek(); // Debug.Log("Next Scene: " + nextScene); // Update background color if (colorDictionary == null) { Debug.LogError("Oh boy, we've got a null dictionary"); } else if (colorDictionary.ContainsKey(nextScene)) { nextSceneBackgroundColor = colorDictionary[nextScene]; // Debug.Log("Found background color for next scene '" + nextScene + "' (" + nextSceneBackgroundColor + ")"); } else { Debug.LogWarning("No background color entry for scene '" + nextScene + "'"); } mainCamera = Camera.main; // Get the current scene color currentSceneBackgroundColor = mainCamera.backgroundColor; }