Exemplo n.º 1
0
    //void StartAction(float speedUp) { StartCoroutine(RotateCamera(2f, -speedUp, "End rotation")); }

    // switch between scenas
    public void NextScene(int delta)  // switch scenes
    //utility.logDebug("NextScene cur="+ curScene +" delta="+ delta);
    //utility.logDebug("Next");
    {
        isActionSave             = false;
        isHintDisplay            = false;
        isDisplayTimer           = false;
        animVR                   = false;
        trDirect                 = false;
        SceneEventSystem.enabled = false;
        //Camera.main.GetComponent<GvrPointerPhysicsRaycaster>().enabled = false;
        // Debug.Log("curScene=" + curScene +" delta="+ delta+" "+ JsonUtility.ToJson(curSnenaMotionData));
        curScene += delta;
        if (!dataSended)
        {
            if (delta > 0)
            {
                testData.snenasMotionData.Add(curSnenaMotionData);
            }
            curfocusObjCode = new int[11] {
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            //curSnenaMotionData = new SnenaMotionData(){i = curScene, act = new List<int[]>()};
            Debug.Log(JsonUtility.ToJson(curSnenaMotionData));
            curSnenaMotionData = new SnenaMotionData()
            {
                i = 0, act = new List <UserActivity>()
            };
        }
        if (rootObj)
        {
            Destroy(rootObj);
        }
        if (TimerCanvas)
        {
            Destroy(TimerCanvas);
        }
        switch (curScene)
        {
        case -1:     // change language menu
            rootObj = utility.ShowSwitchlngMenu(userLang);
            StartCoroutine(utility.rotateText(rootObj, true, 2, "", 0));
            trDirect = true;
            break;

        case 0:     // show a intro message
            Debug.Log("Start 0 scene");
            rootObj = utility.ShowMessage(Data.getMessage(userLang, "Intro"), "Next", Data.getMessage(userLang, "btnNext"), new Vector2(1200, 400), TextAnchor.MiddleCenter, new Vector2(0, 40));
            utility.CreateButton(rootObj.transform.GetChild(0).gameObject.transform.GetChild(0).gameObject.transform, "LangSw", Data.getMessage(userLang, "btnLangSw"), "LangSw", "", new Vector3(400, 230, 0), new Vector2(400, 60));
            try {
                txtVR = (GameObject)Instantiate(Resources.Load <GameObject>("VR"));
                addVR(rootObj, new Vector3(0f, 5, 0));
                animVR = true;
            }
            catch (System.Exception e) { Debug.Log("Can not load VR nodel"); }
            trDirect = true;
            break;

        case 1:     // show a select gender message
            rootObj  = utility.ShowGenderMenu(userLang);
            trDirect = true;
            break;

        case 2:     // show a select birthday message
            rootObj  = utility.ShowDigitsKeyboard(userLang, "Birth");
            trDirect = true;
            break;

        case 3:     // show a start test 1 message
            curTestIndex = 0;
            string msg1 = string.Format(Data.getMessage(userLang, "Test1"), Data.getMessage(userLang, "color_" + testsConfig[curTestIndex, 0]), Data.getMessage(userLang, "obj_" + testsConfig[curTestIndex, 0]));
            //Debug.Log("Test1=" + msg1);
            rootObj = utility.ShowMessage(msg1, "Next", Data.getMessage(userLang, "btnStart"), new Vector2(1200, 400), TextAnchor.MiddleCenter, new Vector2(0, 40));
            StartCoroutine(utility.rotateText(rootObj, true, 2, "newObj", 0));
            trDirect = true;
            break;

        case 4:     // start test 1
            curTestIndex   = 0;
            rootObj        = utility3D.CreateObjsArray(false);
            isHintDisplay  = true;
            isDisplayTimer = false;
            break;

        case 5:     // show a start test 2 message
            curTestIndex = 1;
            string msg2 = string.Format(Data.getMessage(userLang, "Test2"), Data.getMessage(userLang, "color_" + testsConfig[curTestIndex, 1]), Data.getMessage(userLang, "obj_" + testsConfig[curTestIndex, 0]), testsConfig[curTestIndex, 5]);
            rootObj = utility.ShowMessage(msg2, "Next", Data.getMessage(userLang, "btnStart"), new Vector2(1200, 400), TextAnchor.MiddleCenter, new Vector2(0, 40));
            utility3D.createTarget(rootObj, testsConfig[0, 1]);
            trDirect = true;
            break;

        case 6:     //start test 2 with a time limit
            curTestIndex   = 1;
            rootObj        = utility3D.CreateObjsArray(true);
            isHintDisplay  = true;
            isDisplayTimer = true;
            break;

        case 7:     // show a color test start message
            rootObj  = utility.ShowMessage(Data.getMessage(userLang, "IntroColTest"), "Next", Data.getMessage(userLang, "btnStart"), new Vector2(1200, 400), TextAnchor.MiddleCenter, new Vector2(0, 40));
            trDirect = true;
            break;

        case 8:     // start color test
            //Debug.Log("Start color test "+JsonUtility.ToJson(testData.colorTestResult));
            if (testData.colorTestResult.selected != null)
            {
                testData.colorTestResult.selected.Clear();
            }
            else
            {
                testData.colorTestResult.selected = new List <TestAnswer>();
            }
            Debug.Log("Start color test " + JsonUtility.ToJson(testData.colorTestResult));
            testData.colorTestResult.energy    = 0;
            testData.colorTestResult.stress    = 0;
            testData.colorTestResult.totalTime = 0;
            //Debug.Log("Start color test " + JsonUtility.ToJson(testData.colorTestResult));
            rootObj = colorTest.showColors("selAllCol");
            GameObject msgObj2 = utility.ShowMessage(Data.getMessage(userLang, "selAllCol"), "", Data.getMessage(userLang, "btnStart"), new Vector2(1200, 200), TextAnchor.MiddleCenter, new Vector2(0, 20));
            msgObj2.transform.SetParent(rootObj.transform);
            msgObj2.transform.position = new Vector3(0, 5.4f, 16);
            trDirect = true;
            break;

        case 9:     // show a start text test message
            string strTxtIntro = string.Format(Data.getMessage(userLang, "IntroTextTest"), Data.getQuestionsCount(userLang));
            rootObj  = utility.ShowMessage(strTxtIntro, "Next", Data.getMessage(userLang, "btnStart"), new Vector2(1200, 400), TextAnchor.MiddleCenter, new Vector2(0, 40));
            trDirect = true;
            break;

        case 10:     // start a text test
            initTable();
            NextQuestion();
            trDirect = true;
            break;

        case 11:     // show results
            //initTable(); // for test only!!
            rootObj = utility.showResult(userLang, testData.colorTestResult.stress, testData.colorTestResult.energy, testData.textTestResult.Name1, testData.textTestResult.Name2, testData.textTestResult.Value1, testData.textTestResult.Value2, testData.textTestResult.Power);
            StartCoroutine(utility.rotateText(rootObj, true, 2, "", 0));
            trDirect          = true;
            isTimerShowResult = true;
            break;

        case 12:     // show a start text test message
            rootObj = utility.ShowMessage(Data.getMessage(userLang, "msgAbout"), "Back", Data.getMessage(userLang, "btnBack"), new Vector2(1200, 600), TextAnchor.MiddleCenter, new Vector2(0, 40));
            StartCoroutine(utility.rotateText(rootObj, true, 2, "", 0));
            trDirect = true;
            break;

        default: Debug.Log("Not Found current scene index"); break;
        }
        userSceneDataTime[0]     = 0f;
        userSceneDataTime[1]     = 0f;
        trackingTime[1]          = 0f;
        SceneEventSystem.enabled = true;
        actFrmsCnt = 0;
        if (!dataSended)
        {
            isActionSave = true;
        }
    }