Пример #1
0
    void Start()
    {
        GameObject experiment = GameObject.FindWithTag("Experiment");

        manager = experiment.GetComponent("Experiment") as Experiment;
        log     = manager.dblog;
    }
Пример #2
0
        private static Comparison Log(dbLog log, dbCom comp, Expression val, params Expression[] values)
        {
            Comparison whr = new Comparison();

            whr.comparator = val.ToString();
            whr.type       = comp;
            whr.values     = values.Select(v => v.ToString()).ToList();
            return(whr);
        }
Пример #3
0
    void Start()
    {
        cameraCon = player.transform as Transform;
        cameraRig = camerarig.transform as Transform;

        experiment = GameObject.FindWithTag("Experiment");
        manager    = experiment.GetComponent("Experiment") as Experiment;
        log        = manager.dblog;
        avatar     = transform;
    }
Пример #4
0
    public void Start()
    {
        avatar           = GameObject.Find("Avatar");
        hud              = avatar.GetComponent("HUD") as HUD;
        avatarController = avatar.GetComponent("AvatarController") as AvatarController;

        experiment = GameObject.FindWithTag("Experiment");
        manager    = experiment.GetComponent("Experiment") as Experiment;
        log        = manager.dblog;
    }
Пример #5
0
    void Start()
    {
        lastInterval = Time.realtimeSinceStartup;
        frames       = 0;
        intensity    = 1.0f;
        score        = 0;

        experiment = GameObject.FindWithTag("Experiment");
        manager    = experiment.GetComponent("Experiment") as Experiment;
        log        = manager.dblog;
    }
Пример #6
0
        /// <summary>Devuelve los caracteres especificos para la operación lógica solicitada</summary>
        protected string dbLogToString(dbLog log)
        {
            switch (log)
            {
            case dbLog.And:
                return("AND");

            case dbLog.Or:
                return("OR");

            case dbLog.Where:
                return("");
            }
            return("");
        }
Пример #7
0
    public virtual void startTask()
    {
        avatar            = GameObject.FindWithTag("Player");
        avatarLog         = avatar.GetComponent("avatarLog") as avatarLog; //jdstokes 2015
        hud               = avatar.GetComponent("HUD") as HUD;
        experiment        = GameObject.FindWithTag("Experiment");
        manager           = experiment.GetComponent("Experiment") as Experiment;
        firstPersonCamera = manager.playerCamera;
        overheadCamera    = manager.overheadCamera;
        log               = manager.dblog;
        vrEnabled         = manager.usingVR;

        // set up vrInput if we're using VR
        if (vrEnabled)
        {
            vrInput = SteamVR_Input.GetActionSet <SteamVR_Input_ActionSet_vrtk>(default);
Пример #8
0
    void Awake()
    {
        Cursor.visible = false;
        //since config is a singleton it will be the one created in scene 0 or this scene
        config = Config.instance;

        avatar           = GameObject.Find("Avatar");
        hud              = avatar.GetComponent("HUD") as HUD;
        avatarController = avatar.GetComponent("AvatarController") as AvatarController;

        logfile    = config.subjectPath + "/test.log";
        configfile = config.expPath + "/" + config.filename;

        hud.showOnlyHUD();
        //when in editor
        if (!config.bootstrapped)
        {
            logfile    = Directory.GetCurrentDirectory() + "/data/tmp/" + "test.log";
            configfile = Directory.GetCurrentDirectory() + "/data/tmp/" + config.filename;
        }

        if (config.runMode == ConfigRunMode.NEW)
        {
            dblog = new dbLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.RESUME)
        {
            dblog = new dbPlaybackLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.PLAYBACK)
        {
            CharacterController c = avatar.GetComponent <CharacterController>();
            c.detectCollisions = false;
            dblog = new dbPlaybackLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.DEBUG)
        {
            dblog = new dbMockLog(logfile);
        }

        //start session
    }
Пример #9
0
    void Start()
    {
        //controller = avatar.GetComponent("Character Controller") as CharacterController;

        //controller = avatar.GetComponent<CharacterController>();
        controller = gameObject.GetComponent <CharacterController>();
        avatar     = transform;
        // Make the rigid body not change rotation
        if (GetComponent <Rigidbody>())
        {
            GetComponent <Rigidbody>().freezeRotation = true;
        }
        originalRotation = avatar.localRotation;

        bootstrapped = Config.instance.bootstrapped;

        experiment = GameObject.FindWithTag("Experiment");
        manager    = experiment.GetComponent("Experiment") as Experiment;
        log        = manager.dblog;
    }
Пример #10
0
    public static void parse(string filepath, dbLog log)
    {
        Debug.Log("#########   " + filepath);
        if (File.Exists(filepath))
        {
            StreamReader file = new StreamReader(filepath);
            string       line = file.ReadLine();

            int lineNum = 1;

            while (line != null)
            {
                line = line.Trim();
                if (line.IndexOf("#") != 0 && line.Length > 1)
                {
                    ConfigOverrides.set_keyvalue(line, "Line: " + lineNum, log);
                }
                line = file.ReadLine();
                lineNum++;
            }
        }
    }
Пример #11
0
    public static void set_keyvalue(string line, string lineNum, dbLog log)
    {
        string go         = "";
        string code       = "";
        string key        = "";
        string val        = "";
        string typestring = "";

        string[] keyvalue = new string[1];
        string[] parts    = new string[1];

        try {
            keyvalue = line.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
            if (keyvalue.Length != 2)
            {
                throw new ConfigFormatException();
            }

            val = keyvalue[1].Trim();

            parts = keyvalue[0].Trim().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 3)
            {
                throw new ConfigKeyFormatException();
            }



            go   = parts[0];
            code = parts[1];
            key  = parts[2];

            GameObject taskObject = GameObject.Find(go);
            if (!taskObject)
            {
                throw new GameObjectNullException();
            }

            Component script = taskObject.GetComponent(code) as Component;
            if (!script)
            {
                throw new ScriptNullException();
            }

            Type         valType;
            BindingFlags flags;
            FieldInfo    fi = script.GetType().GetField(key, BindingFlags.Instance | BindingFlags.Public);

            // don't care if key is a field or property
            if (fi == null)
            {
                PropertyInfo pi = script.GetType().GetProperty(key, BindingFlags.Instance | BindingFlags.Public);
                if (pi == null)
                {
                    throw new MissingKeyException();
                }
                else
                {
                    typestring = pi.PropertyType.ToString();
                    valType    = pi.PropertyType;
                    flags      = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty;
                }
            }
            else
            {
                valType    = fi.FieldType;
                typestring = fi.FieldType.ToString();
                flags      = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetField;
            }

            // try to convert value to correct type
            object converted = null;
            if (valType.IsEnum)
            {
                converted = Enum.Parse(valType, val, true);
            }
            else
            {
                converted = Convert.ChangeType(val, valType);
            }
            if (converted == null)
            {
                throw new InvalidCastException();
            }

            //set via reflection
            script.GetType().InvokeMember(key, flags, null, script, new object[] { converted });
            log.log("CONFIG_SET	" + keyvalue[0].Trim() + "\t" + keyvalue[1].Trim(), 1);
        } catch (ConfigFormatException) {
            Debug.Log(lineNum + "  Configuration '" + line + "' has invalid format.\nValid config format is 'Session.Game Object name.Script Type.Variable = value'");
        } catch (ConfigKeyFormatException) {
            Debug.Log(lineNum + "  Configuration key '" + key.Trim() + "' has invalid format.\nValid config format is 'Session.Game Object name.Script Type.Variable'");
        } catch (GameObjectNullException) {
            Debug.Log(lineNum + "  Unable to find game object: " + go);
        } catch (ScriptNullException) {
            Debug.Log(lineNum + "  Unable to find script: " + code);
        } catch (MissingKeyException) {
            Debug.Log(lineNum + "  Key: " + key + " Not found in " + go + "." + code);
        } catch (FormatException) {
            Debug.Log(lineNum + "  Unable to set " + go + "." + code + "." + key + " to " + val + ". Was expecting to be formated for " + typestring);
        } catch (InvalidCastException) {
            Debug.Log(lineNum + "  Unable to convert " + val + " to " + typestring);
        } catch (ArgumentException e) {
            Debug.Log("Line: " + lineNum + "  " + e.ToString());
        }
    }
Пример #12
0
 private Expression(dbLog log, Comparison comp)
 {
     particles.Add(new Particle(log, comp));
 }
Пример #13
0
 /// <summary>Operacion para expresiones lógicas compuestas</summary>
 private Expression Operate(dbLog log, Expression expr)
 {
     return(Op(new Particle(log, expr)));
 }
Пример #14
0
 /// <summary>Operacion para expresiones lógicas</summary>
 private Expression Operate(dbLog log, Comparison comp)
 {
     return(Op(new Particle(log, comp)));
 }
Пример #15
0
    void Awake()
    {
        // check if we have any old Landmarks instances from LoadScene.cs and handle them
        GameObject oldInstance = GameObject.Find("OldInstance");

        if (oldInstance != null)
        {
            foreach (var item in oldInstance.transform)
            {
                //Destroy(item); // this tends to break the steamvr skeleton buttons and hand rendermodels
                oldInstance.SetActive(false);
            }
        }

        Debug.Log("Starting Experiment.cs");

        //since config is a singleton it will be the one created in scene 0 or this scene
        config = Config.instance;

        // ------------------------------------------
        // Grab the Landmarks items that are not controller dependent
        // ------------------------------------------
        tasks          = GameObject.Find("LM_Timeline").GetComponent <TaskList>();
        overheadCamera = GameObject.Find("OverheadCamera").GetComponent <Camera>();
        // Assign the scaled player if it's in the scene, otherwise instantiate to avoid errors
        scaledPlayer = GameObject.Find("SmallScalePlayerController");
        // find Environment
        environment = GameObject.FindGameObjectWithTag("Environment");
        // find scaled environment
        if (GameObject.FindGameObjectsWithTag("ScaledEnvironment") != null)
        {
            scaledEnvironment = GameObject.FindGameObjectWithTag("ScaledEnvironment");
            scaledEnvironment.SetActive(false);
        }


        if (PlayerPrefs.GetString("UserInterface") != "default")
        {
            Debug.Log("Getting user interface from config file.");

            switch (config.ui)
            {
            case "Desktop":
                userInterface = UserInterface.DesktopDefault;
                break;

            case "Vive Virt.":
                userInterface = UserInterface.ViveAndVirtualizer;
                break;

            case "Vive Std.":
                userInterface = UserInterface.ViveRoomspace;
                break;

            default:
                break;
            }
        }

        // ------------------------------------------
        // Assign Player and Camera based on UI enum
        // ------------------------------------------


        switch (userInterface)
        {
        case UserInterface.DesktopDefault:
            // Standard Desktop with Keyboard/mouse controller
            player       = GameObject.Find("DesktopDefaultController");
            playerCamera = GameObject.Find("DesktopDefaultCamera").GetComponent <Camera>();

            // Render the overhead camera on the main display (none)
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.None;

            // create variable to indicate if using VR
            usingVR = false;

            break;

        case UserInterface.ViveRoomspace:

            // HTC Vive and Cyberith Virtualizer
            player       = GameObject.Find("ViveRoomspaceController");
            playerCamera = GameObject.Find("VRCamera").GetComponent <Camera>();

            // Render the overhead camera to each lense of the HMD
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.Both;

            // create variable to indicate if using VR
            usingVR = true;

            break;

        case UserInterface.ViveAndVirtualizer:

            // This is a proprietary asset that must be added to the _Landmarks_ prefab to work
            // If it is not added (either for lack of need or lack of the proprietary SDK), use the default
            if (GameObject.Find("ViveVirtualizerController") == null)
            {
                Debug.Log("UserInterface player controller not found. Falling back to Default");
                goto default;
            }

            // HTC Vive and Cyberith Virtualizer
            player       = GameObject.Find("ViveVirtualizerController");
            playerCamera = GameObject.Find("ViveVirtualizerCamera").GetComponent <Camera>();

            // Render the overhead camera to each lense of the HMD
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.Both;

            // create variable to indicate if using VR
            usingVR = true;

            break;

        default:
            // Standard Desktop with Keyboard/mouse controller
            player       = GameObject.Find("DesktopDefaultController");
            playerCamera = GameObject.Find("DesktopDefaultCamera").GetComponent <Camera>();

            // Render the overhead camera on the main display (none)
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.None;

            // create variable to indicate if using VR
            usingVR = false;

            break;
        }

        Debug.Log(player.name);
        // Tag the selected playerController
        player.tag = "Player";
        // Deactivate all other controllers
        foreach (Transform child in GameObject.Find("PlayerControllers").transform)
        {
            if (child.name != player.name)
            {
                child.gameObject.SetActive(false);
            }
        }

        // Add audiolistener to camera (default one should be removed on on all LM_playerControllers)
        // This ensures there will only be one in the scene, attached to the active camera
        playerCamera.gameObject.AddComponent <AudioListener>();

        // Set up Overhead Camera (for map task or any other top-down viewed tasks)
        overheadCamera = GameObject.Find("OverheadCamera").GetComponent <Camera> ();

        // ------------------------------------------
        // Configure Player properties
        // ------------------------------------------

        playerCamera.enabled   = true;
        overheadCamera.enabled = false;
        Cursor.visible         = false;


        // Set the avatar and hud
        avatar = player;
        hud    = avatar.GetComponent("HUD") as HUD;
        hud.showOnlyHUD();


        // ------------------------------------------
        // Handle the config file
        // ------------------------------------------
        logfile    = config.subjectPath + "/" + PlayerPrefs.GetString("expID") + "_" + config.subject + "_" + config.level + ".log";
        configfile = config.expPath + "/" + config.filename;

        //when in editor
        if (!config.bootstrapped)
        {
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "/data/tmp/"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/data/tmp/");
            }
            logfile    = Directory.GetCurrentDirectory() + "/data/tmp/" + "test.log";
            configfile = Directory.GetCurrentDirectory() + "/data/tmp/" + config.filename;

            PlayerPrefs.SetString("expID", "TEST");
        }

        if (config.runMode == ConfigRunMode.NEW)
        {
            dblog = new dbLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.RESUME)
        {
            dblog = new dbPlaybackLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.PLAYBACK)
        {
            CharacterController c = avatar.GetComponent <CharacterController>();
            c.detectCollisions = false;
            dblog = new dbPlaybackLog(logfile);
        }

        //start session

        dblog.log("EXPERIMENT:\t" + PlayerPrefs.GetString("expID") + "\tSUBJECT:\t" + config.subject +
                  "\tSTART_SCENE\t" + config.level + "\tSTART_CONDITION:\t" + config.condition + "\tUI:\t" + userInterface.ToString(), 1);

        Debug.Log(XRSettings.loadedDeviceName);
    }
Пример #16
0
 public Particle(dbLog log, Expression expr)
 {
     Operation = dbOpe.Log;
     Log       = log;
     SetValue(expr);
 }
Пример #17
0
 public Particle(dbLog log, Comparison comp)
 {
     Operation = dbOpe.Log;
     Log       = log;
     Compar    = comp;
 }
Пример #18
0
    void Awake()
    {
        Debug.Log("Starting Experiment.cs");

        // ------------------------------------------
        // Grab the Landmarks Tasks GameObject (Timeline)
        // ------------------------------------------
        tasks = GameObject.Find("LM_Timeline").GetComponent <TaskList>();


        // ------------------------------------------
        // Assign Player and Camera based on UI enum
        // ------------------------------------------

        if (userInterface == UserInterface.DesktopDefault)
        {
            // Standard Desktop with Keyboard/mouse controller
            player       = GameObject.Find("DesktopDefaultController");
            playerCamera = GameObject.Find("DesktopDefaultCamera").GetComponent <Camera> ();

            // Render the overhead camera on the main display (none)
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.None;

            // create variable to indicate if using VR
            usingVR = false;
        }
        else if (userInterface == UserInterface.ViveAndVirtualizer)
        {
            // HTC Vive and Cyberith Virtualizer
            player       = GameObject.Find("ViveVirtualizerController");
            playerCamera = GameObject.Find("ViveVirtualizerCamera").GetComponent <Camera> ();

            // Render the overhead camera to each lense of the HMD
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.Both;

            // create variable to indicate if using VR
            usingVR = true;
        }
        else if (userInterface == UserInterface.ViveRoomspace)
        {
            // HTC Vive and Cyberith Virtualizer
            player       = GameObject.Find("ViveRoomspaceController");
            playerCamera = GameObject.Find("VRCamera").GetComponent <Camera>();

            // Render the overhead camera to each lense of the HMD
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.Both;

            // create variable to indicate if using VR
            usingVR = true;
        }
        else
        {
            // If nothing else, load the default player from the first if() section
            Debug.Log("The selected interface is not yet configured. Using DefaultDesktopPlayerController.");
            player       = GameObject.Find("DesktopDefaultController");
            playerCamera = GameObject.Find("DesktopDefaultCamera").GetComponent <Camera> ();

            // Render the overhead camera on the main display (none)
            overheadCamera.stereoTargetEye = StereoTargetEyeMask.None;

            // create variable to indicate if using VR
            usingVR = false;
        }

        Debug.Log(player.name);
        // Tag the selected playerController
        player.tag = "Player";
        // Deactivate all other controllers
        foreach (Transform child in GameObject.Find("PlayerControllers").transform)
        {
            if (child.name != player.name)
            {
                child.gameObject.SetActive(false);
            }
        }

        // Add audiolistener to camera (default one should be removed on on all LM_playerControllers)
        // This ensures there will only be one in the scene, attached to the active camera
        playerCamera.gameObject.AddComponent <AudioListener>();

        // Set up Overhead Camera (for map task or any other top-down viewed tasks)
        overheadCamera = GameObject.Find("OverheadCamera").GetComponent <Camera> ();

        // ------------------------------------------
        // Configure Player properties
        // ------------------------------------------

        playerCamera.enabled   = true;
        overheadCamera.enabled = false;
        Cursor.visible         = false;
        //since config is a singleton it will be the one created in scene 0 or this scene
        config = Config.instance;

        // Set the avatar and hud
        avatar = player;
        hud    = avatar.GetComponent("HUD") as HUD;

        logfile    = config.subjectPath + "/test.log";
        configfile = config.expPath + "/" + config.filename;

        hud.showOnlyHUD();
        //when in editor
        if (!config.bootstrapped)
        {
            logfile    = Directory.GetCurrentDirectory() + "/data/tmp/" + "test.log";
            configfile = Directory.GetCurrentDirectory() + "/data/tmp/" + config.filename;
        }

        if (config.runMode == ConfigRunMode.NEW)
        {
            dblog = new dbLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.RESUME)
        {
            dblog = new dbPlaybackLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.PLAYBACK)
        {
            CharacterController c = avatar.GetComponent <CharacterController>();
            c.detectCollisions = false;
            dblog = new dbPlaybackLog(logfile);
        }
        else if (config.runMode == ConfigRunMode.NEW)
        {
            //dblog = new dbMockLog(logfile);
        }


        // If a scaledPlayer isn't being used or wasn't created, instantiate the prefab to avoid errors
        if (scaledPlayer == null)
        {
            scaledPlayer = (GameObject)Instantiate(Resources.Load("LM_ScaledPlayer"));
        }


        //start session
    }