Example #1
0
    void Update()
    {
        if (PereferalTest.targetIsFront)
        {
            GameObject test = UnityTargetRotation.GetTempTargetArray();

            //探索対象のオブジェクトの2次元位置を求める
            var target2dpos = Camera.main.WorldToScreenPoint(test.transform.position);

            //カメラの視野をpixelで求める
            //Debug.Log("target2dpos: " + target2dpos + "    camWidth: " + camWidth + "     camHeight: " + camHeight);

            //視野の-paramFOVpxから,+paramFOVpxまでの範囲にGameObjectが入っているかどうかを確認
            if (-paramFOV <= target2dpos.x && target2dpos.x <= camWidth + paramFOV && -paramFOV <= target2dpos.y && target2dpos.y <= camHeight + paramFOV)
            {
                //Debug.Log("target is in the FOV");
                //この場合、中心視を使う
                if (UnityTargetRotation.phase != 2 && (PlayModeSelecter.GetMode() == 4 || PlayModeSelecter.GetMode() == 0))
                {
                    //if (PereferalTest.targetIsFront)
                    //PereferalTest.arrow.SetActive(true);
                }
                //周辺視をOFF
                //SockertSend.SetDirectionFlag(false);
                UnityTargetRotation.viewPortFlag = true;
            }
            else
            {
                //Debug.Log("target is not in the FOV");
                //この場合、周辺視を使う
                UnityTargetRotation.viewPortFlag = false;
                //PereferalTest.arrow.SetActive(false);

                //周辺視をON
                if (PlayModeSelecter.GetMode() == 2 || PlayModeSelecter.GetMode() == 4 || PlayModeSelecter.GetMode() == 0)
                {
                    //SockertSend.SetDirectionFlag(true);
                    ;
                }
                else
                {
                    ;
                }
                //SockertSend.SetDirectionFlag(false);
            }
        }
    }
    //スペースを押したときの動作
    void ProceesPhase()
    {
        GameObject box = GameObject.Find("Cube" + AnnotationIds[CurrentAnnotationId]);


        //待機状態→探索フェーズ
        if (phase == 0 && TargetTracker.screenArea.Contains(TargetTracker.targetPoint))
        {
            //時間計測スタート

            duration = Time.time;
            SockertSend.SetNumFlag(true);
            int mode = PlayModeSelecter.GetMode();
            if (mode == 2 || mode == 4 || mode == 0)
            {
                TaskText.text = BoxIds[AnnotationIds[CurrentAnnotationId] - 1] + "を探せ";
                TargetTracker.targetObject = BoxAnnotations[AnnotationIds[CurrentAnnotationId] - 1];
            }

            if (mode == 3 || mode == 4 || mode == 0)
            {
                SockertSend.SetDirectionFlag(true);
            }
            else
            {
                SockertSend.SetDirectionFlag(false);
            }

            targetAudio = BoxAnnotations[AnnotationIds[CurrentAnnotationId] - 1].GetComponent <AudioSource>();

            if (select_mode == 2 || select_mode == 4)
            {
                targetAudio.clip = targetClip;
            }

            targetAudio.Play();
            audio1.Play();


            Debug.Log("-----------------");
            Debug.Log("phase 1");
            phase = 1;
        }

        //探索フェーズ→回答フェーズ
        else if (phase == 1)
        {
            audio2.Play();

            //phase3
            //正解/不正解にかかわらずいずれかのBoxを見ている場合は次にすすむ
            bool is_looking_at_box = false;

            if (RayCastTest.GetSelectedGameObject() == BoxAnnotations[AnnotationIds[CurrentAnnotationId] - 1])
            {
                is_looking_at_box = true;
            }


            //正誤送信
            if (is_looking_at_box)
            {
                string name = RayCastTest.GetSelectedGameObject().name.ToString().Substring(4);
                //SockertSend.SetMode(PlayModeSelecter.GetMode());
                SockertSend.SetAnswer(name);
                SockertSend.SetDurationFlag(true);
            }
            //Boxを見ていない場合
            else
            {
                audioNG.Play();
                return;
            }

            //正解の場合次へ
            TargetTracker.targetObject = display;
            targetAudio.clip           = null;
            targetAudio.Play();
            audioOK.Play();
            //box.GetComponent<Renderer>().material.color=BoxInvisibleColor;


            SockertSend.SetDirectionFlag(false);

            SockertSend.SetNumFlag(false);
            duration = Time.time - duration;
            SockertSend.SetDuration(duration);
            Debug.Log("-----------------");
            Debug.Log("phase 2: " + duration);

            MeasureTime[CurrentAnnotationId] = duration;

            //ディスプレイを見たとき
            //数字を表示,時間を記録しない
            CurrentAnnotationId++;



            //修正前 最初に戻る
            //修正後 Endと表示
            if (CurrentAnnotationId == TARGET_MAX)
            {
                csvWrite();
                SockertSend.SetNumFlag(true);
                SockertSend.SetNum("End");
                gameOverFlag = true;
                Debug.Log("-----------------");
                Debug.Log("-----------------");
                Debug.Log("----END----");
                Debug.Log("-----------------");
                Debug.Log("-----------------");
                CurrentAnnotationId--;
            }

            phase = 0;
        }
    }
Example #3
0
    //スペースを押したときの動作
    void ProceesPhase()
    {
        GameObject box = GameObject.Find("Cube" + AnnotationIds[CurrentAnnotationId]);

        /*
         * //モニタを見てるときのみトライアル開始
         *      if (phase==0)
         *      {
         *              if (RayCastTest.GetSelectedGameObject()==display)
         *              {
         *                      Debug.Log("-----------------");
         *                      Debug.Log("phase 1");
         *                      Debug.Log("\tBox name: Cube"+AnnotationIds[CurrentAnnotationId]);
         *                      phase++;
         *              }
         *              else
         *              {
         *                      audioNG.Play();
         *              }
         *      }*/

        //待機状態→探索フェーズ
        if (phase == 0)
        {
            /*
             *          if(CurrentAnnotationId == 0)
             *                  scoreText.text = "「赤い箱」を探せ";
             *          if(CurrentAnnotationId == 1)
             *                  scoreText.text = "「黄色い箱」を探せ";
             *          if(CurrentAnnotationId == 2)
             *                  scoreText.text = "「青い箱」を探せ";
             */

            //カーソルを無効化
            //cursor.SetActive(false);

            //時間計測スタート

            duration = Time.time;
            SockertSend.SetNumFlag(true);
            int mode = PlayModeSelecter.GetMode();
            if (mode == 2 || mode == 4 || mode == 0)
            {
                if (CurrentAnnotationId == 0)
                {
                    scoreText.text = "「赤い箱」を探せ";
                    BoxAnnotations[0].GetComponent <Renderer>().material.color = Color.red;
                }
                if (CurrentAnnotationId == 1)
                {
                    scoreText.text = "「緑の箱」を探せ";
                    BoxAnnotations[1].GetComponent <Renderer>().material.color = Color.green;
                }
                if (CurrentAnnotationId == 2)
                {
                    scoreText.text = "「青い箱」を探せ";
                    BoxAnnotations[2].GetComponent <Renderer>().material.color = Color.blue;
                }
            }

            if (mode == 3 || mode == 4 || mode == 0)
            {
                SockertSend.SetDirectionFlag(true);
            }
            else
            {
                SockertSend.SetDirectionFlag(false);
            }

            audio1.Play();
            Debug.Log("-----------------");
            Debug.Log("phase 2");
            phase = 2;
        }

        //探索フェーズ→回答フェーズ
        else if (phase == 2)
        {
            if (CurrentAnnotationId == 0)
            {
                if (RayCastTest.GetSelectedGameObject() != box)
                {
                    return;
                }
            }

            if (CurrentAnnotationId == 1)
            {
                if (RayCastTest.GetSelectedGameObject() != box)
                {
                    return;
                }
            }


            if (CurrentAnnotationId == 2)
            {
                if (RayCastTest.GetSelectedGameObject() != box)
                {
                    return;
                }
            }

            //カーソルを有効に
            cursor.SetActive(true);
            PereferalTest.arrow.SetActive(false);
            audio2.Play();

            box.GetComponent <Renderer>().material.color = BoxInvisibleColor;
            SockertSend.SetDirectionFlag(false);

            SockertSend.SetNumFlag(false);
            duration = Time.time - duration;
            SockertSend.SetDuration(duration);
            Debug.Log("-----------------");
            Debug.Log("phase 3: " + duration);


            //phase3
            //正解/不正解にかかわらずいずれかのBoxを見ている場合は次にすすむ
            bool is_looking_at_box = false;


            for (int i = 0; i < OBJECT_MAX; i++)
            {
                if (RayCastTest.GetSelectedGameObject() == BoxAnnotations[i])
                {
                    is_looking_at_box = true;
                    break;
                }
            }


            //正誤送信
            if (is_looking_at_box)
            {
                string name = RayCastTest.GetSelectedGameObject().name.ToString().Substring(4);
                //SockertSend.SetMode(PlayModeSelecter.GetMode());
                SockertSend.SetAnswer(name);
                SockertSend.SetDurationFlag(true);
            }
            //Boxを見ていない場合
            else
            {
                audioNG.Play();
                return;
            }


            //いずれかのBoxを見ていた場合
            audioOK.Play();
            box.GetComponent <Renderer>().material.color = BoxInvisibleColor;

            //ディスプレイを見たとき
            //数字を表示,時間を記録しない
            CurrentAnnotationId++;



            //修正前 最初に戻る
            //修正後 Endと表示
            if (CurrentAnnotationId == TARGET_MAX)
            {
                SockertSend.SetNumFlag(true);
                SockertSend.SetNum("End");
                gameOverFlag = true;
                Debug.Log("-----------------");
                Debug.Log("-----------------");
                Debug.Log("----END----");
                Debug.Log("-----------------");
                Debug.Log("-----------------");
                //Debug.Log(gameOverFlag);//201901227
                //CurrentAnnotationId--;
            }

            phase = 0;
        }

        //回答フェーズ(見つけたBoxにカーソルを合わせる)
        else if (phase == 3)
        {
        }
    }
    void UserTask()
    {
        if (phase == 0)
        {
            TaskText.text = "PRESS SPACE KEY";
        }

        if (gameOverFlag)
        {
            TaskText.text = "Thank You";
            return;
        }

        RayCastTest.CheckRaycast();
        string dir = PereferalTest.GetDirection();

        SockertSend.SetDirection(dir);
        SockertSend.SetNum(AnnotationIds[CurrentAnnotationId]);
        SockertSend.SetDurationFlag(false);
        SockertSend.SetMode(PlayModeSelecter.GetMode());
        SockertSend.SetPhase(phase);
        SockertSend.SetDebug(is_debug_mode);
        SockertSend.SetEnter(false);
        SockertSend.SetTrial(CurrentAnnotationId);

        /*
         * if (targetAudio != null)
         * {
         *  if (TargetTracker.screenArea.Contains(TargetTracker.targetPoint))
         *      targetAudio.volume = 1f;
         *  else
         *      targetAudio.volume = 0.3f;
         * }
         */

        if (Input.GetKeyDown(KeyCode.Space))
        {
            ProceesPhase();
            Debug.Log("Key: Space");
        }



        //フラグを全部見てから、最後にSocketを送る
        SockertSend.SyncDisplay(this);

        if (accumuDeltaTime > 1.0f / 30)
        {
            SockertSend.SyncDisplay(this);
            accumuDeltaTime = 0.0f;
        }
        accumuDeltaTime += Time.deltaTime;


        //Status Bar


        try
        {
            string objectName = RayCastTest.GetSelectedGameObject().name;
            StatusbarText.text = "mode: " + PlayModeSelecter.GetMode() + ", "
                                 + "phase: " + phase + ", "
                                 + AnnotationIds[CurrentAnnotationId] + "-" + objectName + ", dir: " + dir;
        }
        catch (System.NullReferenceException)
        {
            StatusbarText.text = "mode: " + PlayModeSelecter.GetMode() + ", "
                                 + "phase: " + phase + ", "
                                 + "-" + "null" + ", dir: " + dir;;
        }
    }
Example #5
0
    void Update()
    {
        float fps = 1f / Time.deltaTime;

        //Debug.LogFormat("{0}fps", fps);

        if (phase == 0)
        {
            scoreText.text = "PRESS SPACE KEY";
        }

        if (gameOverFlag)
        {
            scoreText.text = "Thank You";
            return;
        }

        RayCastTest.CheckRaycast();
        string dir = PereferalTest.GetDirection();

        SockertSend.SetDirection(dir);
        SockertSend.SetNum(AnnotationIds[CurrentAnnotationId]);
        SockertSend.SetDurationFlag(false);
        SockertSend.SetMode(PlayModeSelecter.GetMode());
        SockertSend.SetPhase(phase);
        SockertSend.SetDebug(is_debug_mode);
        SockertSend.SetEnter(false);
        SockertSend.SetTrial(CurrentAnnotationId);

        if (Input.GetKeyDown(KeyCode.Alpha0) ||
            Input.GetKeyDown(KeyCode.Alpha1) ||
            Input.GetKeyDown(KeyCode.Alpha2) ||
            Input.GetKeyDown(KeyCode.Alpha3) ||
            Input.GetKeyDown(KeyCode.Alpha4)
            )
        {
            SetDebugMode(is_debug_mode);
            CurrentAnnotationId = 0;
            phase               = 0;
            duration            = 0.0;
            CurrentAnnotationId = 0;
            gameOverFlag        = false;
        }
        if (Input.GetKeyDown(KeyCode.Home))
        {
            LoadGame();
            Debug.Log("Key: Home");
        }

        if (Input.GetKeyDown(KeyCode.End))
        {
            SaveGame();
            Debug.Log("Key: End");
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            is_debug_mode = !is_debug_mode;
            SetDebugMode(is_debug_mode);
            Debug.Log("Key: P");
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            ForwardTempArray();
            Debug.Log("Key: F");
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            BackTempArray();
            Debug.Log("Key: B");
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            ProceesPhase();
            Debug.Log("Key: Space");
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (is_current_patternA)
            {
                AnnotationIds       = patternB;
                is_current_patternA = false;
            }
            else
            {
                AnnotationIds       = patternA;
                is_current_patternA = true;
            }

            Debug.Log("Key: Tab");
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            SockertSend.SetEnter(true);
            SetDebugMode(is_debug_mode);
            CurrentAnnotationId = 0;
            phase               = 0;
            duration            = 0.0;
            CurrentAnnotationId = 0;
            Debug.Log("Key: Enter");
        }

        if (is_current_patternA)
        {
            SockertSend.SetPattern("A");
        }
        else
        {
            SockertSend.SetPattern("B");
        }

        //フラグを全部見てから、最後にSocketを送る
        SockertSend.SyncDisplay(this);

        if (accumuDeltaTime > 1.0f / 30)
        {
            SockertSend.SyncDisplay(this);
            accumuDeltaTime = 0.0f;
        }
        accumuDeltaTime += Time.deltaTime;


        //Status Bar


        try
        {
            string objectName = RayCastTest.GetSelectedGameObject().name;
            textTarget.text = "mode: " + PlayModeSelecter.GetMode() + ", "
                              + "phase: " + phase + ", "
                              + AnnotationIds[CurrentAnnotationId] + "-" + objectName + ", dir: " + dir;
        }
        catch (System.NullReferenceException)
        {
            textTarget.text = "mode: " + PlayModeSelecter.GetMode() + ", "
                              + "phase: " + phase + ", "
                              + "-" + "null" + ", dir: " + dir;;
        }
    }