Пример #1
0
    void FixedUpdate()
    {
        if (timeRecordForTotal)
        {
            Duration_for_total += Time.deltaTime;
        }
        if (timeRecordForWalking)
        {
            Duration_for_walk += Time.deltaTime;
        }
        if (timeRecordForRunning_constantSpeed)
        {
            Duration_for_run_constantSpeed += Time.deltaTime;
        }

        if (IsExploring)
        {
            timeRecordForTotal = true;
            diff_betw_2Points  = subject_response_position - FirstPersonController.m_CharacterController.transform.position;
            distance_to_center = Vector3.Distance(subject_response_position, FirstPersonController.m_CharacterController.transform.position);
            if (distance_to_center > 0.25f)               // give head motion
            {
                if (distance_to_center <= distance_to_center_showing_motion_1 & !motion_1_finished)
                {
                    motion_1_finished = true;
                    practice_fmri_item_subject_person head_movement = wooden_fence.GetComponent <practice_fmri_item_subject_person> ();
                    person_who_head_moved.Add(headmovement_order.ElementAt(0));
                    head_movement.start_headMovement(headmovement_order.ElementAt(0));
                }
                if (distance_to_center <= distance_to_center_showing_motion_2 & !motion_2_finished)
                {
                    motion_2_finished = true;
                    practice_fmri_item_subject_person head_movement = wooden_fence.GetComponent <practice_fmri_item_subject_person> ();
                    person_who_head_moved.Add(headmovement_order.ElementAt(0));
                    head_movement.start_headMovement(headmovement_order.ElementAt(0));
                }
                if (distance_to_center <= distance_to_center_showing_motion_3 & !motion_3_finished)
                {
                    motion_3_finished = true;
                    practice_fmri_item_subject_person head_movement = wooden_fence.GetComponent <practice_fmri_item_subject_person> ();
                    person_who_head_moved.Add(headmovement_order.ElementAt(0));
                    head_movement.start_headMovement(headmovement_order.ElementAt(0));
                }

                // walking & run controller
                if (distance_to_center > point_to_run)
                {
                    timeRecordForWalking = true;
                    moving_direction     = new Vector3(diff_betw_2Points.normalized.x, -0.1f, diff_betw_2Points.normalized.z);
                    FirstPersonController.m_CharacterController.Move(moving_direction * initial_speed * Time.deltaTime);
                }
                else if (distance_to_center <= point_to_run)
                {
                    //if(!walking_finsih){
                    //	walking_finsih = true;
                    //	Application.CaptureScreenshot(trial_ith_formal_exp_stage3 + "_walking.png");
                    //}
                    timeRecordForWalking = false;
                    //	UnityEngine.Debug.Log ("Duration_for_walk" + Duration_for_walk);
                    speedup_duration -= Time.deltaTime;
                    if (speedup_duration > 0)
                    {
                        initial_speed    = initial_speed + 0.125f;                      //+ 0.121f
                        moving_direction = new Vector3(diff_betw_2Points.normalized.x, -0.1f, diff_betw_2Points.normalized.z);
                        FirstPersonController.m_CharacterController.Move(moving_direction * initial_speed * Time.deltaTime);
                    }
                    if (speedup_duration <= 0)
                    {
                        timeRecordForRunning_constantSpeed = true;
                        moving_direction = new Vector3(diff_betw_2Points.normalized.x, -0.1f, diff_betw_2Points.normalized.z);
                        FirstPersonController.m_CharacterController.Move(moving_direction * initial_speed * Time.deltaTime);
                    }
                }
            }
            else
            {
                timeRecordForRunning_constantSpeed = false;
                timeRecordForTotal = false;
                //				UnityEngine.Debug.Log ("Duration_for_run_constantSpeed" + Duration_for_run_constantSpeed);
                //				UnityEngine.Debug.Log ("Duration_for_total" + Duration_for_total);
                Duration_for_total             = 0;
                Duration_for_walk              = 0;
                Duration_for_run_constantSpeed = 0;

                // who did not move head? add to list
                if (headmovement_order.Count != 0)
                {
                    for (int i = 0; i < headmovement_order.Count; i++)
                    {
                        person_who_head_NOT_moved.Add(headmovement_order.ElementAt(i));
                    }
                }

                IsExploring = false;
                FirstPersonController.NO_MOVE = true;
                if ((isIn_formal_exp_stage1 & trial_ith_formal_exp_stage1 < 2) |
                    (isIn_formal_exp_stage2 & trial_ith_formal_exp_stage2 < 2))
                {
                    isPausing_inst_walkingEnd = true;
                }
                else
                {
                    walking_end();
                }
            }
        }
    }