Inheritance: MonoBehaviour
Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        RayCastTest.CheckRaycast();

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (RayCastTest.GetSelectedGameObject() == StartObj_A)
            {
                Debug.Log("Start");
                UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
            }

            Debug.Log("Key: Space");
        }
    }
    //スペースを押したときの動作
    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;;
        }
    }
Beispiel #4
0
    void Update()
    {
        if (this.gameObject == RayCastTest.GetSelectedGameObject())
        {
            //Debug.Log("raycastによってオブジェクトが選択されました。移動する際はキーボード入力を用いてください。");
            /*Yの位置姿勢を変更する*/
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.y += 0.01f;
                    currentObj[i].transform.position = pos;
                }
                //Debug.Log("UpArrow");
            }
            //下矢印
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.y -= 0.01f;
                    currentObj[i].transform.position = pos;
                }

                //Debug.Log("DownArrow");
            }
            //C
            else if (Input.GetKeyDown(KeyCode.C))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.x += 0.01f;
                    currentObj[i].transform.position = pos;
                }

                //Debug.Log("C");
            }
            //V
            else if (Input.GetKeyDown(KeyCode.V))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.x -= 0.01f;
                    currentObj[i].transform.position = pos;
                }

                //Debug.Log("V");
            }
            //D
            else if (Input.GetKeyDown(KeyCode.D))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.z += 0.01f;
                    currentObj[i].transform.position = pos;
                }

                //Debug.Log("D");
            }
            //F
            else if (Input.GetKeyDown(KeyCode.F))
            {
                for (int i = 0; i < MAX; i++)
                {
                    Vector3 pos = currentObj[i].transform.position;
                    pos.z -= 0.01f;
                    currentObj[i].transform.position = pos;
                }

                //Debug.Log("F");
            }
        }
        else
        {
            ;
        }
    }
Beispiel #5
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)
        {
        }
    }
Beispiel #6
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;;
        }
    }
Beispiel #7
0
 private void Awake()
 {
     Instance = this;
 }