示例#1
0
    // when player wants to go to next level
    public void ContinueNextLevel()
    {
        CollectableManager.Instance.Score += currentScore;

        CheckpointResult result = new CheckpointResult();

        result.medal            = currentMedal;
        result.score            = currentScore;
        result.level            = SceneTransition.Instance.CurrentLevel;
        result.maxPossibleScore = numCollectables;

        CollectableManager.Instance.AddCheckpointResult(result);

        // something else?
        // destroy singleton
        instance = null;

        if (SceneTransition.Instance.IsLastLevel)
        {
            OnGameFinish();
        }
        else
        {
            SceneTransition.Instance.GoToNextLevel();
            Destroy(gameObject);
        }
    }
示例#2
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);         // destroy object when player goes to next level
    }