コード例 #1
0
    public Vector3 SetDirection()
    {
        ExpMangerObject = GameObject.Find("ExperimentManager");
        m_expCue        = ExpMangerObject.GetComponent <ExpCue>();

        // get target direction
        bool rightDirection = m_expCue.activeTarget.GetComponent <TargetMotion>().moveRight;

        // make list of possible x and y directions depending on target
        List <float> xDir = new List <float>();
        List <float> yDir = new List <float>();

        if (rightDirection)
        {
            xDir.Add(-1);
            xDir.Add(Mathf.Sqrt(2) / -2);

            yDir.Add(0);
            yDir.Add(Mathf.Sqrt(2) / 2);
            yDir.Add(Mathf.Sqrt(2) / -2);

            // maybe
            xDir.Add(Mathf.Sqrt(2) / 2);
            yDir.Add(Mathf.Sqrt(2) / 2);
            yDir.Add(Mathf.Sqrt(2) / -2);
        }
        else if (!rightDirection)
        {
            xDir.Add(1);
            xDir.Add(Mathf.Sqrt(2) / 2);

            yDir.Add(0);
            yDir.Add(Mathf.Sqrt(2) / 2);
            yDir.Add(Mathf.Sqrt(2) / -2);

            // maybe
            xDir.Add(Mathf.Sqrt(2) / -2);
            yDir.Add(Mathf.Sqrt(2) / 2);
            yDir.Add(Mathf.Sqrt(2) / -2);
        }

        // randomly select x and y directions
        int xIndex = Random.Range(0, xDir.Count);
        int yIndex = Random.Range(0, yDir.Count);

        float randX = xDir[xIndex];
        float randY = yDir[yIndex];

        //float randX = Random.Range(-1f, 1f);
        //float randY = Random.Range(-1f, 1f);
        direction = new Vector3(randX, randY, 0f);

        // calculate magnitude of motion vector
        magnitude = Mathf.Pow(randX, 2f) + Mathf.Pow(randY, 2); // x^2 + y^2
        magnitude = Mathf.Sqrt(magnitude);                      // sqrt(x^2 + y^2)

        return(direction);
    }
コード例 #2
0
    void Start()
    {
        // Script references
        m_ExpSetup = this.GetComponent <ExpSetup>();
        m_ExpCue   = this.GetComponent <ExpCue>();

        // Find flicker objects
        //rightFlicker = GameObject.Find("RightMotion_Flicker");
        //leftFlicker = GameObject.Find("LeftMotion_Flicker");
        photocell = GameObject.Find("Photocell");
    }
コード例 #3
0
    void Start()
    {
        // Setup script references
        m_ExpSetup      = this.GetComponent <ExpSetup>();
        m_ExpCue        = this.GetComponent <ExpCue>();
        m_ExpPeripheral = this.GetComponent <ExpPeripheral>();
        m_ExpTrial      = this.GetComponent <ExpTrial>();

        m_TrialInfoData  = this.GetComponent <TrialInfoData>();
        m_FlickerManager = this.GetComponent <FlickerManager>();

        // Setup peripheral display references
        occluderRef.AddRange(GameObject.FindGameObjectsWithTag("Occluder"));
        peripheralDisplayRef = GameObject.Find("Peripheral Display");
        m_SpawnPeriperal     = peripheralDisplayRef.GetComponent <SpawnPeripheral>();

        // Setup fixation gameobject reference
        fixationObjectRef = GameObject.Find("FixationCross");

        // Setup trial counter references
        trialCounterRef = GameObject.Find("TrialCounter");
        m_TrialNumber   = trialCounterRef.GetComponent <TrialNumber>();
        trialCounterRef.SetActive(false);                           // hide trial counter

        // Setup input field references
        inputGameobjectRef = GameObject.Find("InputField");
        inputGameobjectRef.SetActive(false);                        // hide text input field

        // Setup feedback references
        feedbackGameobjectRef = GameObject.Find("Feedback");
        feedbackGameobjectRef.SetActive(false);                     // hide feedback object

        // Setup instruction references
        instructionsRef = GameObject.Find("Instructions");

        // Setup coherence manager references
        coherenceManagerRef = GameObject.Find("CoherenceManager");
        if (coherenceManagerRef != null)
        {
            m_AdjustCoherence = coherenceManagerRef.GetComponent <AdjustCoherence>();
        }

        // Adjust coherence level for current subject using calibration data
        //if (adjustCoherence)
        //    totalNum = m_AdjustCoherence.coherenceNum;
    }
コード例 #4
0
    void Start()
    {
        // Initialize variables
        expCueRef       = GameObject.Find("ExperimentManager").GetComponent <ExpCue>(); // access the ExpCue.m script on ExperimentManager gameobject
        rightFlickerRef = rightFlickerObject.GetComponent <FlickerMaterial>();          // access the FlickerMaterial.m script on rightward gameobject
        leftFlickerRef  = leftFlickerObject.GetComponent <FlickerMaterial>();           // access the FlickerMaterial.m script on leftward gameobject

        // Create filepath/filename for CSV file
        expPath = FileName();
        //Debug.Log(expPath);

        // Write first line of CSV with variable labels corresponding to the following lines
        string newLine = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                       "Target Direction", "Right Freq", "Left Freq", "Peripheral Direction", "Total Central Dots",
                                       "Number Targets", "Response", "Target Times");

        csv.AppendLine(newLine);
    }
コード例 #5
0
    private void Awake()
    {
        // Setup script references
        m_ExpSetup = this.GetComponent <ExpSetup>();
        m_ExpCue   = this.GetComponent <ExpCue>();

        // Find flicker objects
        //rightFlicker = GameObject.Find("RightMotion_Flicker");
        //leftFlicker = GameObject.Find("LeftMotion_Flicker");
        photocell = GameObject.Find("Photocell");

        // Make list of both flicker objects
        flickerObjects.Add(rightFlicker);
        flickerObjects.Add(leftFlicker);
        flickerObjects.Add(photocell);

        rightFlickerStartPosition = rightFlicker.transform.position;
        leftFlickerStartPosition  = leftFlicker.transform.position;
    }
コード例 #6
0
 void Start()
 {
     m_ExpCue = this.GetComponent <ExpCue>();
 }