示例#1
0
 private void Update()
 {
     if (LevelManager.GetCar().Physics.LinearVelocity.magnitude > this.speed)
     {
         AutograderManager.CompleteTask(this);
     }
 }
 /// <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 OnTriggerEnter(Collider other)
    {
        Racecar racecar = other.GetComponentInParent <Racecar>();

        if (racecar != null)
        {
            AutograderManager.CompleteTask(this);
        }
    }
示例#4
0
    private void Update()
    {
        // Reset angle and distance so they are recalculated this frame
        this.angle    = null;
        this.distance = null;

        if (this.autograderTask == null)
        {
            LevelManager.ShowMessage($"Angle: {this.Angle:F1} degrees\nDistance: {this.Distance:F1} cm", this.IsSuccess ? Color.green : Color.white, -1);
        }
        else if (this.IsSuccess && LevelManager.GetCar().Physics.LinearVelocity.magnitude < Constants.MaxStopSeed)
        {
            // TODO: Find a way to display Angle and Distance
            AutograderManager.CompleteTask(this.autograderTask);
        }
    }
    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);
        }
    }
示例#6
0
    protected override void Update()
    {
        base.Update();

        if (Mathf.Abs(this.Distance - this.goalDistance) < this.allowableDistanceError)
        {
            this.text.color = Color.green;
            if (LevelManager.GetCar().Physics.LinearVelocity.magnitude < Constants.MaxStopSeed)
            {
                // The autograder task must be stored as a separate script due to the inheritance structure
                AutograderManager.CompleteTask(this.GetComponent <AutograderTask>());
            }
        }
        else
        {
            this.text.color = Color.white;
        }
    }
    private void OnTriggerStay(Collider other)
    {
        Racecar racecar = other.GetComponentInParent <Racecar>();

        if (racecar != null)
        {
            if (racecar.Physics.LinearVelocity.magnitude < this.maxStopSpeed)
            {
                this.startTime = Mathf.Min(this.startTime, Time.time);
                if (Time.time - this.startTime >= DestinationStop.stopDuration)
                {
                    AutograderManager.CompleteTask(this);
                }
            }
            else
            {
                this.startTime = float.MaxValue;
            }

            this.material.color = new Color(this.material.color.r, this.material.color.g, this.material.color.b, this.Alapha);
        }
    }
 private void Awake()
 {
     AutograderManager.instance = this;
     this.tasks = this.GetComponentsInChildrenOrdered <AutograderTask>();
 }
示例#9
0
 /// <summary>
 /// Return to the main menu.
 /// </summary>
 public void MainMenu()
 {
     AutograderManager.ResetAutograder();
     SceneManager.LoadScene(LevelCollection.MainMenuBuildIndex, LoadSceneMode.Single);
 }