예제 #1
0
    void SetState(TaskState aState)
    {
        _taskState = aState;
        Debug.Log($"task state: {_taskState}");

        if (_taskState == TaskState.NotStarted)
        {
            // do nothing
        }
        else if (_taskState == TaskState.AttentionGrabber)
        {
            attentionGrabber.SetActive(true);
            attentionGrabber.GetComponent <AttentionGrabber>().Run();

            _focusDetector.SetTrackingObject(attentionGrabber);
            _hrClient.AttentionGrabber();
        }
        else if (_taskState == TaskState.GazeDown)
        {
            attentionGrabber.GetComponent <AttentionGrabber>().Stop();
            attentionGrabber.SetActive(false);

            var actor = _trial.Actor;
            var head  = _trial.Head;

            _image.Show($"{actor}-{head}-down");
            // _focusDetector.SetTrackingObject(_image.faceImage);

            _hrClient.OrientationGazeDownward(actor, head);

            Invoke(nameof(NextState), gazeDownwardDuration);
        }
        else if (_taskState == TaskState.GazeUp)
        {
            var actor = _trial.Actor;
            var head  = _trial.Head;
            var gaze  = _trial.Gaze;

            _image.Show($"{actor}-{head}-up-{gaze[0]}");
            // _focusDetector.SetTrackingObject(_image.faceImage);

            if (gaze == OrientationTrial.GazeDirections.Straight.ToString().ToLower() ||
                gaze == OrientationTrial.GazeDirections.Forward.ToString().ToLower())
            {
                _hrClient.OrientationGazeStraight(actor, head);
            }
            else
            {
                _hrClient.OrientationGazeAverted(actor, head);
            }

            Invoke(nameof(NextState), gazeUpwardDuration);
        }
        else if (_taskState == TaskState.Finished)
        {
            _image.Finish();
            _log.TrialFinished(_trials.CurrentIndex);
            _hrClient.TrialFinished();

            DisplayRestingMedia();

            Invoke(nameof(ResetState), INTER_TRIAL_MIN_DURATION);
        }
        else
        {
            throw new IndexOutOfRangeException($"SetState: task is in unsupported state: {_taskState}");
        }
    }