Exemple #1
0
    // called to begin transition to new level, when current level is complete
    public void GoToNextLevel()
    {
        if (levelNamesIndex >= levelNames.Length - 1)       // if I'm on the last level
        {
            Debug.Log("All levels complete.");
            OnAllLevelsComplete.Invoke(this);
            return;
        }
        player.rb.isKinematic = true;
        currentLevel.player   = null;

        // get difference between start and current pose
        playerSlide = loadedLevel.GetStartPoint().position + Vector3.up * levelSeparationDistance - player.transform.position;

        Debug.Log("Going to level " + loadedScene.name + " from " + currentScene.name);
        if (!nextLevelReady)
        {
            // wait for level load
            Debug.Log("Waiting for next level to load...");
            OnLevelLoaded.AddListener(WaitForLoad);
            return;
        }
        levelProgess    = 0f;
        levelTransition = true;
    }
Exemple #2
0
    public static void StartListening(string eventName, UnityAction listener)
    {
        LevelEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new LevelEvent();
            thisEvent.AddListener(listener);
            instance.eventDictionary.Add(eventName, thisEvent);
        }
    }