/// <summary>
 /// Handles when the user exits to the main menu (escape).
 /// </summary>
 private void HandleExit()
 {
     this.SetTimeScale(1.0f);
     this.UpdateBestTimes();
     this.pythonInterface.HandleExit();
     LevelManager.cachedPythonInterface = null;
     AutograderManager.ResetAutograder();
     SceneManager.LoadScene(LevelCollection.MainMenuBuildIndex, LoadSceneMode.Single);
 }
    private void Start()
    {
        this.FindKeyPoints();
        this.SpawnPlayers();     // Depends on FindKeyPoints to find the start keypoint
        this.SetTimeScale(1.0f); // Depends on SpawnPlayers to create the screen manager

        switch (LevelManager.LevelManagerMode)
        {
        case LevelManagerMode.Exploration:
            if (LevelManager.LevelInfo.HelpMessage != null)
            {
                this.screenManager.ShowMessage(LevelManager.LevelInfo.HelpMessage, Color.white);
            }
            break;

        case LevelManagerMode.Autograder:
            this.autograderManager = GetComponentInChildren <AutograderManager>();

            // First autograder trial for level: set build index, wait for user to start
            if (LevelManager.cachedPythonInterface == null)
            {
                LevelManager.autograderBuildIndex = LevelManager.LevelInfo.AutograderBuildIndex;
                AutograderManager.ResetAutograder();
                this.screenManager.ShowMessage("To begin the autograder, connect a Python program and press START (or enter).", Color.white);
            }

            // Not the first autograder trial for level: load python interface from cache, automatically start
            else
            {
                this.pythonInterface = LevelManager.cachedPythonInterface;
                this.screenManager.UpdateConnectedPrograms(this.pythonInterface.ConnectedPrograms);
                this.HandleStart();
            }
            break;

        case LevelManagerMode.Race:
            this.keyPointDurations = new float[this.keyPoints.Length];
            this.screenManager.UpdateTime(0.0f, this.keyPointDurations);
            break;
        }

        if (this.pythonInterface == null)
        {
            this.pythonInterface = new PythonInterface();
            this.screenManager.UpdateConnectedPrograms(this.pythonInterface.ConnectedPrograms);
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Return to the main menu.
 /// </summary>
 public void MainMenu()
 {
     AutograderManager.ResetAutograder();
     SceneManager.LoadScene(LevelCollection.MainMenuBuildIndex, LoadSceneMode.Single);
 }