Exemple #1
0
    // Reloads the managers and displays the loading screen after scene reloads.
    // Ensures correct timing between scene load and finding of objects.
    IEnumerator TimeActionsWithSceneLoaded()
    {
        // Time the actions.
        yield return(new WaitForEndOfFrame());

        // Update the managers to the ones loaded in the new scene.
        sharedVariableManager = GameObject.Find("SharedVariableManager").GetComponent <SharedVariableManager>();
        overlayManager        = GameObject.Find("OverlayCanvas").GetComponent <OverlayManager>();
        robotViewText         = GameObject.Find("RobotViewText").GetComponent <Text>();

        // Set the approprite robot view text.
        switch (trials[currentTrialNum].trialType)
        {
        case TrialType.AI:
            robotViewText.text = AIText;
            break;

        case TrialType.HUMAN:
            robotViewText.text = humanText;
            break;
        }

        // Display the loading screen depending on the type of trial.
        overlayManager.DisplayLoadingScreen(trials[currentTrialNum].trialType);

        // Load the appropriate models for the player and robot avatars.
        assetLoader.LoadPlayerAvatar(experimentDataManager.appearance.gender, experimentDataManager.appearance.skinColor);
        assetLoader.LoadRobotAvatar(trials[currentTrialNum].robotType, trials[currentTrialNum].robotColor);

        // Load the appropriate environment.
        assetLoader.LoadEnvironment(trials[currentTrialNum].environmentType);
    }
Exemple #2
0
    IEnumerator TimeActionsWithFirstSceneLoaded()
    {
        // Make sure that this script is executed after all the others.
        yield return(new WaitForEndOfFrame());

        // Find all the objects required by this class.
        assetLoader           = GameObject.Find("AssetLoader").GetComponent <AssetLoader>();
        experimentDataManager = GameObject.Find("ExperimentDataManager").GetComponent <ExperimentDataManager>();
        overlayManager        = GameObject.Find("OverlayCanvas").GetComponent <OverlayManager>();
        sharedVariableManager = GameObject.Find("SharedVariableManager").GetComponent <SharedVariableManager>();
        robotViewText         = GameObject.Find("RobotViewText").GetComponent <Text>();

        // Set up list of robot colors.
        List <RobotColor> colors = new List <RobotColor>();

        colors.Add(RobotColor.BLUE);
        colors.Add(RobotColor.RED);
        colors.Add(RobotColor.PURPLE);
        colors.Add(RobotColor.YELLOW);
        colors.Add(RobotColor.PINK);
        colors.Add(RobotColor.GREEN);
        colors.Add(RobotColor.BROWN);
        colors.Add(RobotColor.ORANGE);
        colors.Add(RobotColor.BLACK);
        colors.Add(RobotColor.SPECIAL);
        colors.Shuffle();

        // Initialize trials list as empty.
        trials = new List <Trial>();

        // Trial list construction.
        // Add trials. This is dependent on the experiment design.
        if (debugTrials)
        {
            // Add the trials.
            // trials.Add(new Trial(EnvironmentType.BASIC, RobotType.PR2, TrialType.AI));
            // trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            // trials.Add(new Trial(EnvironmentType.NARROW, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
        }
        else if (testingTrials)
        {
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
        }
        else
        {
            // Add the trials.
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.PR2, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.AI));
            trials.Add(new Trial(EnvironmentType.OPEN, RobotType.SOPHIA, TrialType.HUMAN));
        }

        // Set colors. Colors are assigned randomly in a way, looped around for the number of trials.
        for (int i = 0; i < trials.Count; ++i)
        {
            trials[i].robotColor = colors[i % colors.Count];
        }

        // Shuffle the trials.
        trials.Shuffle();

        // Add the test trial to the front of the list (should always be first!).
        trials.Insert(0, new Trial());
        // End trial list construction.

        // Load the trial environment.
        assetLoader.LoadEnvironment(trials[currentTrialNum].environmentType);

        // Display the first trial's loading screen.
        overlayManager.DisplayLoadingScreen(trials[currentTrialNum].trialType);

        // Subscribe the new scene actions to future scene loads.
        // Needs to be here in order to not perform NewSceneActions for the first trial.
        SceneManager.sceneLoaded += NewSceneActions;
    }