void VarInit()
    {
        BoxAnnotations = new GameObject[OBJECT_MAX];
        for (int i = 0; i < OBJECT_MAX; i++)
        {
            //GameObjectを格納
            BoxAnnotations[i] = m_TargetObj[i];
        }
        DebugLog = GameObject.Find("DebugLog");

        //変数の初期化
        phase = 0;
        CurrentAnnotationId = 0;
        viewPortFlag        = false;

        SockertSend.SetNum(0);
        SockertSend.SetMode(0);
        SockertSend.SetTrial(0);
        SockertSend.SetNumFlag(false);
        SockertSend.SetDuration(0.0);
        SockertSend.SetAnswer("00");
        SockertSend.SetDurationFlag(false);
        SockertSend.SetDirectionFlag(false);
        SockertSend.SetDirection("no");
        SockertSend.SyncDisplay(this);
    }
Exemple #2
0
 public static void ResetTempTargetArray(int mode)
 {
     //display.SetActive(true);
     SockertSend.SetNumFlag(false);
     CurrentAnnotationId = 0;
     phase        = 0;
     gameOverFlag = false;
 }
Exemple #3
0
    void VarInit()
    {
        //変数の初期化
        phase = 0;
        CurrentAnnotationId = 0;
        viewPortFlag        = false;

        cursor = GameObject.Find("Panel");
        //display=GameObject.Find("Display");

        BoxAnnotations = new GameObject[OBJECT_MAX];

        for (int i = 0; i < OBJECT_MAX; i++)
        {
            //GameObjectを格納
            BoxAnnotations[i] = GameObject.Find("Cube" + BoxIds[i]);
            BoxAnnotations[i].GetComponent <Renderer>().material.color = BoxInvisibleColor;
        }

        DebugLog = GameObject.Find("DebugLog");

        for (int i = 0; i < OBJECT_MAX; i++)
        {
            //テクスチャ変更
            BoxAnnotations[i].GetComponent <Renderer>().material.mainTexture = targetTexture;
        }

        //Displayと名の付くオブジェクトを代入
        //PereferalTest.arrow.SetActive(false);

        SockertSend.SetNum(0);
        SockertSend.SetMode(0);
        SockertSend.SetTrial(0);
        SockertSend.SetNumFlag(false);
        SockertSend.SetDuration(0.0);
        SockertSend.SetAnswer("00");
        SockertSend.SetDurationFlag(false);
        SockertSend.SetDirectionFlag(false);
        SockertSend.SetDirection("no");
        SockertSend.SyncDisplay(this);
    }
    //スペースを押したときの動作
    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;
        }
    }
    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;;
        }
    }
    void Update()
    {
        float fps = 1f / Time.deltaTime;

        //Debug.Log(DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"));

        if (select_mode == 0)
        {
            if (Input.GetKeyDown("r") && Input.GetKey("x"))
            {
                transform.Rotate(new Vector3(0.5f, 0, 0));
            }

            if (Input.GetKeyDown("l") && Input.GetKey("x"))
            {
                transform.Rotate(new Vector3(-0.5f, 0, 0));
            }
            if (Input.GetKeyDown("r") && Input.GetKey("y"))
            {
                transform.Rotate(new Vector3(0, 0.5f, 0));
            }
            if (Input.GetKeyDown("l") && Input.GetKey("y"))
            {
                transform.Rotate(new Vector3(0, -0.5f, 0));
            }

            if (Input.GetKeyDown("r") && Input.GetKey("z"))
            {
                transform.Rotate(new Vector3(0, 0, 0.5f));
            }
            if (Input.GetKeyDown("l") && Input.GetKey("z"))
            {
                transform.Rotate(new Vector3(0, 0, -0.5f));
            }

            //情報提示パターンの選択
            TaskText.text = "提示パターン選択";

            if (Input.GetKeyDown("1"))
            {
                //中心視
                select_mode = 1;
                arrowObj.SetActive(true);
                DebugLog.SetActive(false);
                StatusbarText.enabled = false;
                InvBoxColor();
            }
            else if (Input.GetKeyDown("2"))
            {
                //音像定位
                select_mode = 2;
                arrowObj.SetActive(false);
                DebugLog.SetActive(false);
                StatusbarText.enabled = false;
                InvBoxColor();
            }
            else if (Input.GetKeyDown("3"))
            {
                //周辺視のみ
                select_mode = 3;
                arrowObj.SetActive(false);
                DebugLog.SetActive(false);
                StatusbarText.enabled = false;
                InvBoxColor();
            }
            else if (Input.GetKeyDown("4"))
            {
                //Debugモード
                select_mode = 4;
                arrowObj.SetActive(true);
                DebugLog.SetActive(true);
                StatusbarText.enabled = true;
                LookBoxColor();
            }

            if (select_mode != 0)
            {
                audio2.Play();
            }
        }



        if (select_mode != 0 && AnnotationIds == null)
        {
            TaskText.text = "探索パターンを選択";

            if (Input.GetKeyDown("a"))
            {
                AnnotationIds = patternA;
                TARGET_MAX    = 10;
            }
            else if (Input.GetKeyDown("b"))
            {
                AnnotationIds = patternB;
                TARGET_MAX    = 10;
            }
            else if (Input.GetKeyDown("c"))
            {
                AnnotationIds = patternC;
                TARGET_MAX    = 10;
            }
            else if (Input.GetKeyDown("d"))
            {
                AnnotationIds = patternD;
                TARGET_MAX    = 3;
            }
            else if (Input.GetKeyDown("e"))
            {
                AnnotationIds = patternE;
                TARGET_MAX    = 3;
            }
            else if (Input.GetKeyDown("f"))
            {
                AnnotationIds = patternF;
                TARGET_MAX    = 3;
            }
        }

        if (select_mode != 0 && AnnotationIds != null)
        {
            UserTask();
        }


        if (Input.GetKeyDown(KeyCode.Return))
        {
            SockertSend.SetEnter(true);
            SockertSend.SetNum(0);
            SockertSend.SetMode(0);
            SockertSend.SetTrial(0);
            SockertSend.SetNumFlag(false);
            SockertSend.SetDuration(0.0);
            SockertSend.SetAnswer("00");
            SockertSend.SetDurationFlag(false);
            SockertSend.SetDirectionFlag(false);
            SockertSend.SetDirection("no");
            SockertSend.SyncDisplay(this);
            SetDebugMode(is_debug_mode);
            phase               = 0;
            duration            = 0.0;
            CurrentAnnotationId = 0;
            select_mode         = 0;
            gameOverFlag        = false;
            AnnotationIds       = null;
            DebugLog.SetActive(true);
            MeasureTime = new double[10];
            TargetTracker.targetObject = display;
            Debug.Log("Key: Enter");
        }
    }
Exemple #7
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)
        {
        }
    }
Exemple #8
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;;
        }
    }