Example #1
0
        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);
            }
        }
Example #2
0
        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;
        }
Example #3
0
        IEnumerator LoadStateSaverAndDependants()
        {
            ObstacleType thisObstacle = gameObject.transform.parent.GetComponent(typeof(ObstacleType)) as ObstacleType;

            savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
            yield return(new WaitUntil(() => savedState != null));

            yield return(new WaitUntil(() => thisObstacle != null));

            // TODO: Improve scoring logic for multiple words. (https://trello.com/c/N5kTTiPQ/104-improve-scoring-logic-for-multiple-words)
            savedState.score.setScoreFromWord(savedState.obstacleDictionary[thisObstacle.ObstacleName][0]);
        }
 void Awake()
 {
     savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
 }
Example #5
0
 void Awake()         // I'll fix this sloppy mess later, I swear!
 {
     savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
 }
Example #6
0
 void Awake()
 {
     character  = GetComponent <PlatformerCharacter2D>();
     savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
     runSpeed   = savedState.defaultRunningSpeed;
 }