예제 #1
0
    private void LateUpdate()
    {
        if (isPaused && isInAcceptor)
        {
            //ANIMATION
            instructionController.ShrinkInstructions();
            instructionController.IsStill();

            exampleController.isDoneInstruction = true;

            isPaused = false;

            CancelInvoke("CheckForPause");
        }

        else
        {
            //if cursor is visible..
            if (exampleController.trialType.Contains("rotated") || exampleController.trialType.Contains("clamped") || exampleController.trialType.Contains("aligned"))
            {
                //if cursor is paused AND in target
                if (isPaused && isInTarget)
                {
                    //disable the tracker script (for the return to home position)
                    trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = false;

                    isPaused   = false;
                    isInTarget = false;

                    CancelInvoke("CheckForPause");

                    targetReached = true;

                    //Destroy old target
                    targetHolderController.DestroyTarget();

                    //Create homeposition
                    homePosition.SetActive(true);
                }

                if (isPaused && isInHome && exampleController.isDoneInstruction)
                {
                    //Turn off home
                    homePosition.SetActive(false);

                    isInHome = false;
                    //isPaused = false;

                    CancelInvoke("CheckForPause");

                    //Create random target
                    //Vector3 newTargetPosition = new Vector3(UnityEngine.Random.Range(-0.25f, 0.25f), 0.7f, UnityEngine.Random.Range(0.35f, 0.45f));
                    //Quaternion targetRotation = new Quaternion(0, 0, 0, 0);
                    //Instantiate(target, exampleController.targetPosition, targetRotation);


                    if (targetReached)
                    {
                        targetReached = false;
                        //start the next trial
                        exampleController.EndAndPrepare();
                    }
                    else
                    {
                        if (exampleController.trialInBlock != 1 || exampleController.isInstructionTrial == true)
                        {
                            //Create TARGET
                            targetHolderController.InstantiateTarget();
                        }

                        //enable the tracker script (for the reach to target)
                        trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = true;
                    }
                }
            }

            //if cursor is invisible
            else
            {
                //if cursor is paused
                if (isPaused && !isInHomeArea)
                {
                    //disable the tracker script (for the return to home position)
                    trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = false;

                    isPaused   = false;
                    isInTarget = false;

                    CancelInvoke("CheckForPause");

                    //Destroy old target
                    targetHolderController.DestroyTarget();

                    //Create homeposition
                    homePosition.SetActive(true);

                    // set target reached -- so that a trial can end (in non-noCursor tasks, this happens when people actually reach the target)
                    targetReached = true;
                }

                if (isInHome && isPaused && exampleController.isDoneInstruction)
                {
                    //Turn off home
                    homePosition.SetActive(false);

                    isInHome = false;
                    //isPaused = false;

                    CancelInvoke("CheckForPause");

                    //Create random target
                    //randomize location of target
                    //Vector3 newTargetPosition = new Vector3(UnityEngine.Random.Range(-0.25f, 0.25f), 0.7f, UnityEngine.Random.Range(0.35f, 0.45f));
                    //Quaternion targetRotation = new Quaternion(0, 0, 0, 0);
                    //Instantiate(target, exampleController.targetPosition, targetRotation);

                    if (targetReached)
                    {
                        targetReached = false;
                        //start the next trial
                        exampleController.EndAndPrepare();
                    }
                    else
                    {
                        if (exampleController.trialInBlock != 1 || exampleController.isInstructionTrial == true)
                        {
                            //Create TARGET
                            targetHolderController.InstantiateTarget();
                        }

                        //enable the tracker script (for the reach to target)
                        trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = true;
                    }
                }
            }
        }
    }
예제 #2
0
    //IEnumerator StartRecordingDistance()
    //{
    //    InvokeRepeating("RecordDistance", 0, 1);
    //    yield return null;
    //}



    private void LateUpdate()
    {
        //if cursor is visible..
        if (exampleController.trialType.Contains("rotated") || exampleController.trialType.Contains("clamped") || exampleController.trialType.Contains("aligned"))
        {
            //if cursor is paused AND in target
            if (isPaused && isInTarget)
            {
                //disable the tracker script (for the return to home position)
                trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = false;

                isPaused   = false;
                isInTarget = false;

                CancelInvoke("CheckForPause");

                //make the cursor disappear
                GetComponent <MeshRenderer>().enabled = false;

                //start the next trial
                exampleController.EndAndPrepare();
            }

            if (isPaused && isInHome)
            {
                //Turn off home
                homePosition.SetActive(false);

                isInHome = false;
                isPaused = false;

                CancelInvoke("CheckForPause");

                //make the cursor reappear
                GetComponent <MeshRenderer>().enabled = true;

                //Create target
                //randomize location of target
                //Vector3 newTargetPosition = new Vector3(UnityEngine.Random.Range(-0.25f, 0.25f), 0.7f, UnityEngine.Random.Range(0.35f, 0.45f));
                //Quaternion targetRotation = new Quaternion(0, 0, 0, 0);
                //Instantiate(target, exampleController.targetPosition, targetRotation);

                targetHolderController.InstantiateTarget();

                //enable the tracker script (for the reach to target)
                trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = true;
            }
        }

        //if cursor is invisible
        else
        {
            //NOT CHECKING FOR PAUSE IN HOME FOR NO-CURSORS! FIX THIS
            //if cursor is paused
            if (isPaused && !isInHomeArea)
            {
                //disable the tracker script (for the return to home position)
                trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = false;

                isPaused   = false;
                isInTarget = false;

                CancelInvoke("CheckForPause");

                //make the cursor disappear
                GetComponent <MeshRenderer>().enabled = false;

                //start the next trial
                exampleController.EndAndPrepare();
            }

            if (isInHome && isPaused)
            {
                //Turn off home
                homePosition.SetActive(false);

                isInHome = false;
                isPaused = false;

                CancelInvoke("CheckForPause");

                //make the cursor stay invisible
                GetComponent <MeshRenderer>().enabled = false;

                //Create target
                //randomize location of target
                //Vector3 newTargetPosition = new Vector3(UnityEngine.Random.Range(-0.25f, 0.25f), 0.7f, UnityEngine.Random.Range(0.35f, 0.45f));
                //Quaternion targetRotation = new Quaternion(0, 0, 0, 0);
                //Instantiate(target, exampleController.targetPosition, targetRotation);

                targetHolderController.InstantiateTarget();

                //enable the tracker script (for the reach to target)
                trackerHolderObject.GetComponent <PositionRotationTracker>().enabled = true;
            }
        }
    }