public void SaveNewTestData(DataTested testData)
    {
        string dataString = JsonWriter.Serialize(testData);

        Debug.Log(testData);
        string path = Application.dataPath + "/Resources/Data/TestData_" + Session + ".json";

        System.IO.File.WriteAllText(path, dataString);
        AssetDatabase.ImportAsset("/Resources/Data/TestData_" + Session + ".json");
    }
        //See if there are any subscribers and fire the event
        protected virtual void OnDataTested()
        {
            DataTested?.Invoke();

            /*
             * Or
             * if (DataTested !=Null)
             * {
             * DataTested(this, EventArgs.Empty);
             * }
             */
        }
示例#3
0
    // Use this for initialization
    void Start()
    {
        TextAsset[]       assets       = Resources.LoadAll <TextAsset>("Data");
        string            jsonTemp     = "";
        List <DataTested> testListTemp = new List <DataTested>();

        foreach (var asset in assets)
        {
            DataTested temp = JsonReader.Deserialize <DataTested>(asset.ToString());
            testListTemp.Add(temp);
        }
        jsonTemp = JsonWriter.Serialize(testListTemp.ToArray());
        string path = Application.dataPath + "/Resources/Data/TestDataTotal" + ".json";

        System.IO.File.WriteAllText(path, jsonTemp);
        AssetDatabase.ImportAsset("/Resources/Data/TestDataTotal" + ".json");
        Debug.Log("Saved");
    }
    public IEnumerator TextProcess()
    {
        SetBlind(true);
        TurnOffAll();
        TurnOffAllCue();
        Debug.Log("Start test");
        LastType_1 = 20;
        LastType_2 = 20;
        LastType_3 = 20;

        while (Session < 60)
        {
            //시작하는 스페이스를 기다린다 .
            yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Return)));

            Debug.Log(Session + ": Started session");
            Session++;

            SetBlind(false);

            // 이번회의 타입?
            bool isReadyCondition = false;
            while (!isReadyCondition)
            {
                int ranIntTemp = UnityEngine.Random.Range(0, 3);

                switch (ranIntTemp)
                {
                case 0:
                    if (LastType_1 != 0)
                    {
                        LastType_1--;
                        CurConditionType = (ConditionType)ranIntTemp;
                        isReadyCondition = true;
                    }
                    break;

                case 1:
                    if (LastType_2 != 0)
                    {
                        LastType_2--;
                        CurConditionType = (ConditionType)ranIntTemp;
                        isReadyCondition = true;
                    }
                    break;

                case 2:
                    if (LastType_3 != 0)
                    {
                        LastType_3--;
                        CurConditionType = (ConditionType)ranIntTemp;
                        isReadyCondition = true;
                    }
                    break;
                }
            }
            isReadyCondition = false;
            // 암막치우기

            int answerIndex = UnityEngine.Random.Range(0, 4);


            // 사전 단서 제공하거나 말거나 세팅  .
            switch (CurConditionType)
            {
            case ConditionType.None:

                break;

            case ConditionType.Cueing:
                TurOnCue(Cue[answerIndex]);
                break;

            case ConditionType.FakeCueing:
                int fakeCueIdnex = answerIndex;

                while (fakeCueIdnex == answerIndex)
                {
                    fakeCueIdnex = UnityEngine.Random.Range(0, 4);
                }
                TurOnCue(Cue[fakeCueIdnex]);
                break;
            }
            float ranWaitTime = UnityEngine.Random.Range(3.00f, 6.00f);
            // 3초에서 10초 기다림

            yield return(new WaitForSecondsRealtime(ranWaitTime));

            // 인풋 기다리기 !

            TurnOn(Box[answerIndex]);
            DateTime startTime = DateTime.Now;

            yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Space)));

            DateTime endTime = DateTime.Now;

            TimeSpan time = endTime - startTime;

            string timeStr = String.Format("{0}.{1}", time.Seconds, time.Milliseconds.ToString().PadLeft(3, '0'));

            DataTested newData = new DataTested()
            {
                conditionType = (int)CurConditionType, indexNumber = Session, responseTime = timeStr
            };
            //박스 켰고 ! 기다림

            SaveNewTestData(newData);
            // -> 인풋 받으면 데이터 저장하고 다시 암막 생성하고 모든거 초기화 하고 다시 루프 !
            SetBlind(true);
            TurnOffAll();
            TurnOffAllCue();
        }
        //끝났다고 알려줌
    }