Esempio n. 1
0
 public DataFarmerObject(string tag)
 {
     this.tag         = tag;
     this.timestamp   = Time.time;
     ps               = ParticipantStatus.GetInstance();
     this.participant = ps.GetParticipant();
     this.trial       = ps.GetTrial();
     this.condition   = ps.GetCondition();
     this.category    = ps.GetCategory();
     this.cube        = ps.GetCube();
 }
Esempio n. 2
0
 public void OnTriggerStay(Collider other)
 {
     if (leftController.controller.GetHairTriggerUp() || rightController.controller.GetHairTriggerUp())
     {
         // check if the participant made an answer then move on to next trial
         if (ps.ChoiceMade())
         {
             ps.IncTrial();
             if (ps.IsFinished())
             {
                 SceneManager.LoadScene("FinalScene", LoadSceneMode.Single);
             }
             Debug.Log(string.Format("Starting trial {0} at {1}", ps.GetTrial(), Time.time));
         }
     }
 }
    // Update is called once per frame
    public void Update()
    {
        GameObject cube = GameObject.FindGameObjectWithTag("Interactable Object");

        if (player != null && cube != null)
        {
            if (cube != null)
            {
                Transform transform = cube.GetComponent <Transform>();
                int[]     angles    =
                {
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.right)) - 90.0),
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.up)) - 90.0),
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.forward)) - 90.0),
                };
                int max         = angles.Max();
                int visibleSide = NOSIDE;
                // basic idea: is the cube face angled towards us enough for us to see it?
                // we also want to check if the player's head is rotated up or to the side too far
                if (max > thresholdAngle)
                {
                    visibleSide = angles.ToList().IndexOf(max);
                }

                bool publishUpdate = false;

                if (ps.GetTrial() != trial)
                {
                    trial         = ps.GetTrial();
                    publishUpdate = true;
                }
                else
                {
                    if (visibleSide != previousSide)
                    {
                        publishUpdate = true;
                    }
                }

                if (publishUpdate)
                {
                    // the last Vector3 is a placeholder for the cumulative movement of the head and hand controllers
                    DataFarmer.GetInstance().Save(
                        new DFFixation(
                            "up=" + angles[UP],
                            "forward=" + angles[FORWARD],
                            "right=" + angles[RIGHT],
                            dirStrings[visibleSide],
                            ps.DisplacementsToString()
                            )
                        );
                    previousSide = visibleSide;
                }

                if (detailedLogging && measurements % 20 == 0)
                {
                    angleDisplay.text =
                        "participant " + ps.GetParticipantAsString()
                        + " condition " + ps.GetCondition().ToString() + "\n"
                        + "right " + player.transform.forward[RIGHT]
                        + " up " + player.transform.forward[UP]
                        + "\n" + dirStrings[UP] + " " + angles[UP]
                        + ", " + dirStrings[RIGHT] + " " + angles[RIGHT]
                        + ", " + dirStrings[FORWARD] + " " + angles[FORWARD]
                        + "\n" + dirStrings[visibleSide] + " is facing you"
                        + "\n" + "correct answer is " + ps.GetCategory();
                }
                ;
                measurements++;
            }
        }
    }
Esempio n. 4
0
    //called by buttons' OnClickButton 
    public void Clicked(string clickedTag)
    {
        if (clickedTag == "NEXT")
        {
            if (ps.GetTrial() > 0 && !ps.ChoiceMade()) return;

            //Debug.Log("nex~~~~~");
            //collect data
            if (ps.IsFinished())
            {
                SceneManager.LoadScene("FinalScene", LoadSceneMode.Single);
            }
            Debug.Log("Incrementing Trial");
            ps.IncTrial();

            //Debug.Log(string.Format("Starting trial {0} at {1}", ps.GetTrial(), Time.time));
            //Despawn current box
            this.GetComponent<DespawnObject>().buttonDespawn();
            for (int i = 0; i < choices.Count; i++)
            {
                if (choices[i].GetComponent<CustomTag>().getTag(0) != "NEXT")
                {
                    choices[i].GetComponent<Renderer>().material = noChoiceMat;
                }
                else
                {
                    choices[i].GetComponent<Renderer>().material = neutralMat;
                }
            }
            //Spawn in new box
            this.GetComponent<SpawnRandomBox>().spawn();
            firstChoice = true;
        }
        else
        {
            if (firstChoice == true)
            {
                //collect data
                if (ps.SetChoice(clickedTag))
                {
                    ps.GetDataFarmer().Save(new DFAnswerSelection());
                    //Debug.Log(string.Format("Answer selected: {0}", ps.GetLastChoice()));
                }

                firstChoice = false;
                GameObject[] currentObjs = GameObject.FindGameObjectsWithTag("Interactable Object");
                foreach (GameObject cube in currentObjs)
                {
                    string chosenTag = ParticipantStatus.GetInstance().GetCategory();
                    ParticipantStatus.GetInstance().SetChoice(chosenTag);

                    if (chosenTag == clickedTag)
                    {
                        for (int i = 0; i < choices.Count; i++)
                        {
                            if (choices[i].GetComponent<CustomTag>().getTag(0) != "NEXT")
                            {
                                if (choices[i].GetComponent<CustomTag>().getTag(0) != chosenTag)
                                {
                                    choices[i].GetComponent<Renderer>().material = neutralMat;
                                }
                                else
                                {
                                    choices[i].GetComponent<Renderer>().material = correctMat;
                                }
                            }
                            else
                            {
                                choices[i].GetComponent<Renderer>().material = nextMat;
                            }
                        }
                    }
                    else
                    {

                        for (int i = 0; i < choices.Count; i++)
                        {
                            if (choices[i].GetComponent<CustomTag>().getTag(0) != "NEXT")
                            {
                                if (choices[i].GetComponent<CustomTag>().getTag(0) != chosenTag)
                                {
                                    choices[i].GetComponent<Renderer>().material = neutralMat;
                                }
                                else
                                {
                                    choices[i].GetComponent<Renderer>().material = correctMat;
                                }
                                if (choices[i].GetComponent<CustomTag>().getTag(0) == clickedTag)
                                {
                                    choices[i].GetComponent<Renderer>().material = wrongMat;
                                }
                            }
                            else
                            {
                                choices[i].GetComponent<Renderer>().material = nextMat;
                            }
                        }
                    }
                }
            }
        }
    }