public void SyncTrialInfo(int number, TrialInfo trial)
        {
            if (!isServer)
            {
                return;
            }

            task           = trial.Task;
            trialID        = trial.TrialID;
            targetLocation = trial.TargetLocation;
            roleA          = trial.RoleA;
            b1_val_A       = trial.B1_Val_A;
            b2_val_A       = trial.B2_Val_A;
            b3_val_A       = trial.B3_Val_A;
            roleB          = trial.RoleB;
            b3_val_B       = trial.B3_Val_B;
            b2_val_B       = trial.B2_Val_B;
            b1_val_B       = trial.B1_Val_B;
            trialNumber    = number;
        }
        void GetTrialListAndShuffle()
        {
            List <TrialInfo> saccadeTrials = new List <TrialInfo>();
            List <TrialInfo> reachTrials   = new List <TrialInfo>();
            List <TrialInfo> jointTrials   = new List <TrialInfo>();

            while (!INIT.IsFinished)
            {
                TrialInfo trial = new TrialInfo(INIT.CurrentItem);
                switch (trial.Task)
                {
                case "solo_saccade":
                    saccadeTrials.Add(trial);
                    break;

                case "solo_point":
                    reachTrials.Add(trial);
                    break;

                case "joint":
                    jointTrials.Add(trial);
                    break;

                default:
                    INIT.SubmitError("Error selecting task");         //Make INIT file unavailable.
                    break;
                }
                INIT.NextItem();
            }

            saccadeTrials.Shuffle();
            reachTrials.Shuffle();
            jointTrials.Shuffle();

            Trials.AddRange(saccadeTrials);
            Trials.AddRange(reachTrials);
            Trials.AddRange(jointTrials);
        }
        public void FlushBuffer(DataHolder data, TrialInfo trial, int trialNumber)
        {
            if (Buffer.Count == 0)
            {
                return;
            }
            else
            {
                DateTime time = DateTime.Now;

                string filename = _subjID + "_" + _playerName + "_" + trialNumber.ToString() + "_" + trial.Task + "_TrialID" + trial.TrialID.ToString() + "_Date_" + time.ToString("dd'_'MM'_'yyyy'_'H''mm''ss") + ".csv";

                using (StreamWriter sw = File.CreateText(Path.Combine(_directory, filename)))
                {
                    sw.WriteLine(data.Header);

                    for (int i = 0; i < Buffer.Count; i++)
                    {
                        sw.WriteLine(Buffer[i]);
                    }
                }
                Buffer.Clear();
            }
        }
        IEnumerator RunSoloExperiment()
        {
            IsRunning = true;
            UI_Experimenter.Instance.MirrorsActive = false;

            while (true)
            {
                if (Trials.Count > 0 && INIT.IsAvailable && !SYNCACT.readyState)
                {
                    _trialInfo = Trials[0];
                    switch (_trialInfo.Task)
                    {
                    case "solo_saccade":
                        yield return(SaccadeTask());

                        break;

                    case "solo_point":
                        yield return(ReachTask());

                        break;

                    case "joint":
                        SYNCACT.readyState = true;
                        Debug.Log("Ready for Joint");
                        break;

                    default:
                        INIT.SubmitError("Error selecting task from Trial List");         //Make INIT file unavailable.
                        break;
                    }
                    if (SYNCACT.readyState)
                    {
                        break;
                    }

                    yield return(new WaitForSeconds(_interTrialPeriod));

                    //Peek at next Trial to determine if task is changing. If task is changing, break out of Coroutine.
                    if (Trials.Count > 1)
                    {
                        if (_trialInfo.Task != Trials[1].Task)
                        {
                            Trials.RemoveAt(0);
                            _trialNumber++;
                            UI_Experimenter.Instance.MirrorsActive = true;
                            TurnOn(Blocks);
                            TurnOn(HandInitCube);
                            break;
                        }
                    }
                    Trials.RemoveAt(0);
                    _trialNumber++;
                }
                else
                {
                    break;
                }
            }
            IsRunning = false;
            yield return(null);
        }