SceneController.StartNewScene C# (CSharp) Méthode

StartNewScene() private méthode

private StartNewScene ( ) : IEnumerator
Résultat IEnumerator
    IEnumerator StartNewScene()
    {
        //Assign last map
        //lastMap = currentMap;
        //Create new map
        currentMapQueue++;
        if (currentMapQueue == levelPlan.Length) {
            //if tie, add another map (from one of our previous) and continue
            int max = -1;
            bool tie = false;
            for (int i = 0; i < playerScores.Length; i++) {
                if (playerScores[i] >= max) {
                    tie = false;
                    if (playerScores[i] == max) {
                        tie = true;
                    }
                    max = playerScores[i];
                }

            }
            if (tie) {
                int[] newLevelPlan = new int[levelPlan.Length + 1];
                for (int i = 0; i < levelPlan.Length; i++) {
                    print(levelPlan[i]);
                    newLevelPlan[i] = levelPlan[i];
                }
                newLevelPlan[newLevelPlan.Length - 1] = levelPlan[Random.Range(0, levelPlan.Length - 1)];
                levelPlan = newLevelPlan;
            } else {
                fading = true;
                //we're done, break
                End();

                yield break;

            }

        }
        //print(currentMapQueue);
        int nextMap = levelPlan[currentMapQueue];
        int sceneIndex = nextMap;
        fading = true;
        yield return new WaitForSeconds(2);
        for (int i = 0; i < playerCount; i++) DisconnectPlayers (i);

        yield return new WaitForSeconds(1);

        SceneManager.UnloadScene (lastScene);

        yield return SceneManager.LoadSceneAsync(sceneIndex, LoadSceneMode.Additive);
        lastScene = sceneIndex;
        RespawnPeeps ();
        SpriteSet.ApplySprites(spriteSet); //Apply sprites for this stage
        //currentMap = (GameObject)GameObject.Instantiate(levels[nextMap], nextPosition, Quaternion.identity);
        //Tell camera to move towards another place, will call RespawnPeeps when halfway to next location
        //GameObject.Find("AutoZoomCamParent").SendMessage("SetNewPlace", nextPosition);
        //EditorApplication.isPaused = true;
    }