Esempio n. 1
0
    //private GestureDetector gest;

    // Start is called before the first frame update
    void Start()
    {
        headShaken       = false;
        audios           = cube.GetComponent <AudioSource>();
        audios.enabled   = false;
        _wearableControl = WearableControl.Instance;

        // Establish a requirement for the acceleration sensor
        WearableRequirement requirement = GetComponent <WearableRequirement>();

        if (requirement == null)
        {
            requirement = gameObject.AddComponent <WearableRequirement>();
        }

        requirement.EnableSensor(SensorId.Accelerometer);
        requirement.SetSensorUpdateInterval(SensorUpdateInterval.EightyMs);
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        //count = 0;
        //SetCountText();
        //winText.text = "You Win!";
        //winText.gameObject.SetActive(false);
        //getCount = GameObject.FindGameObjectsWithTag("Pick Up");
        //pickUpCount = getCount.Length;

        wearableControl = WearableControl.Instance;
        WearableRequirement requirement = GetComponent <WearableRequirement>();

        if (requirement == null)
        {
            requirement = gameObject.AddComponent <WearableRequirement>();
        }
        requirement.EnableSensor(SensorId.RotationSixDof);
        requirement.SetSensorUpdateInterval(SensorUpdateInterval.EightyMs);
    }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            RotationMatcher matcher = target as RotationMatcher;

            CheckAndWarnForCameraUsage(matcher);

            EditorGUILayout.HelpBox(DescriptionBox, MessageType.None);
            EditorGUILayout.PropertyField(_rotationSource);
            EditorGUILayout.PropertyField(_updateInterval);

            WearableRequirement requirement = matcher.GetComponent <WearableRequirement>();

            if (Application.isPlaying)
            {
                if (requirement == null || !requirement.enabled)
                {
                    // Runtime, manually removed
                    EditorGUILayout.HelpBox(RequirementRemovedOrDisabledWarning, MessageType.Warning);
                }
            }
            else
            {
                if (requirement == null)
                {
                    // Editor, no user-provided
                    EditorGUILayout.HelpBox(RequirementWillBeCreatedInfo, MessageType.Info);
                }
            }

            if (requirement != null && requirement.enabled)
            {
                // Editor, user provided OR runtime

                // Check sensor validity
                var      source           = (RotationMatcher.RotationSensorSource)_rotationSource.enumValueIndex;
                SensorId rotationSensorId =
                    source == RotationMatcher.RotationSensorSource.SixDof ?
                    SensorId.RotationSixDof :
                    SensorId.RotationNineDof;
                if (!requirement.DeviceConfig.GetSensorConfig(rotationSensorId).isEnabled)
                {
                    if (Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox(RequiredRotationSensorManuallyDisabledWarning, MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(RequirementSensorsWillBeAlteredInfo, MessageType.Info);
                    }
                }

                // Check rate validity
                var interval = (SensorUpdateInterval)_updateInterval.enumValueIndex;
                if (requirement.DeviceConfig.updateInterval.IsSlowerThan(interval))
                {
                    if (Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox(RequiredUpdateIntervalManuallyLoweredWarning, MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(RequirementUpdateIntervalWillBeAlteredInfo, MessageType.Info);
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            RotationMatcher matcher = target as RotationMatcher;

            CheckAndWarnForCameraUsage(matcher);

            EditorGUILayout.HelpBox(DESCRIPTION_BOX, MessageType.None);
            EditorGUILayout.PropertyField(_rotationSource);
            EditorGUILayout.PropertyField(_updateInterval);

            WearableRequirement requirement = matcher.GetComponent <WearableRequirement>();

            if (Application.isPlaying)
            {
                if (requirement == null || !requirement.enabled)
                {
                    // Runtime, manually removed
                    EditorGUILayout.HelpBox(REQUIREMENT_REMOVED_OR_DISABLED_WARNING, MessageType.Warning);
                }
            }
            else
            {
                if (requirement == null)
                {
                    // Editor, no user-provided
                    EditorGUILayout.HelpBox(REQUIREMENT_WILL_BE_CREATED_INFO, MessageType.Info);
                }
            }

            if (requirement != null && requirement.enabled)
            {
                // Editor, user provided OR runtime

                // Check sensor validity
                var      source           = (RotationMatcher.RotationSensorSource)_rotationSource.enumValueIndex;
                SensorId rotationSensorId =
                    source == RotationMatcher.RotationSensorSource.SixDof ?
                    SensorId.RotationSixDof :
                    SensorId.RotationNineDof;
                if (!requirement.DeviceConfig.GetSensorConfig(rotationSensorId).isEnabled)
                {
                    if (Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox(REQUIRED_ROTATION_SENSOR_MANUALLY_DISABLED_WARNING, MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(REQUIREMENT_SENSORS_WILL_BE_ALTERED_INFO, MessageType.Info);
                    }
                }

                // Check rate validity
                var interval = (SensorUpdateInterval)_updateInterval.enumValueIndex;
                if (requirement.DeviceConfig.updateInterval.IsSlowerThan(interval))
                {
                    if (Application.isPlaying)
                    {
                        EditorGUILayout.HelpBox(REQUIRED_UPDATE_INTERVAL_MANUALLY_LOWERED_WARNING, MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(REQUIREMENT_UPDATE_INTERVAL_WILL_BE_ALTERED_INFO, MessageType.Info);
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 5
0
    // Update is called once per frame
    // Mode - 1:Help, 2:Classic, 3:Memory
    void Update()
    {
        if (Input.GetKeyDown("1"))
        {
            if (GameMode == 0)
            {
                GameMode = 1;
                Instruction.SetActive(true);
                //playaudio(13);
                timeold = Time.time;
            }
            else if (GameMode == 1)
            {
                GameMode = 0;
                Instruction.SetActive(false);
                timeold = Time.time;
            }
        }
        else if (Input.GetKeyDown("2"))
        {
            if (initialize == 0)
            {
                wearableControl = WearableControl.Instance;
                WearableRequirement requirement = GetComponent <WearableRequirement>();
                if (requirement == null)
                {
                    requirement = gameObject.AddComponent <WearableRequirement>();
                }

                requirement.EnableSensor(SensorId.RotationSixDof);
                requirement.SetSensorUpdateInterval(SensorUpdateInterval.FortyMs);
                //Debug.Log("Game Started : i = "+ i);
                initialize = 1;
            }
            GameMode = 2;
            playaudio(4);

            timeold = Time.time;
        }
        else if (Input.GetKeyDown("h"))
        {
            score        = score - 100;
            T_Score.text = "Score : " + score;
            if (fb_flip == 1)
            {
                T_FBStatus.text = "Front-Back : Flipped";
            }
            else
            {
                T_FBStatus.text = "Front-Back : Normal";
            }
            if (lr_flip == 1)
            {
                T_LRStatus.text = "Left-Right : Flipped";
            }
            else
            {
                T_LRStatus.text = "Left-Right : Normal";
            }
            T_Hint.text = "";
        }

        if (GameMode > 1)
        {
            SensorFrame sensorFrame = wearableControl.LastSensorFrame;
            movez = sensorFrame.rotationSixDof.value.eulerAngles.z;
            movex = sensorFrame.rotationSixDof.value.eulerAngles.x;
        }

        if (GameMode == 0)
        {
            if (Time.time - timeold >= delay)
            {
                playaudio(14);
                timeold = Time.time;
            }
        }

        /*else if (GameMode == 1){
         *      if(Time.time-timeold >= delay){
         *              GameMode = 0;
         *              T_Score.text = " ";
         *              T_Lives.text = " ";
         *              T_Difficulty.text = " ";
         *              T_LRStatus.text = " ";
         *              T_FBStatus.text = " ";
         *      }
         * }*/
        else if (GameMode == 2)
        {
            if (Time.time - timeold >= delay)
            {
                //Debug.Log("Actually Started : i = "+ i);
                info_mode1 = 0;
                // Checking the head position : Pitch & Roll
                if (ctr != 0 && info_mode == 0)
                {                       //Debug.Log(r_o+","+movex+","+movez);
                                        //Debug.Log("Before Checking : i = "+ i);
                    if (lr_flip == 0)
                    {
                        if (r_o == 1 && !((movez > 270) && (movez < 360 - threshold)))
                        {
                            Wrong_Action();
                        }
                        else if (r_o == 3 && !((movez > threshold) && (movez < 90)))
                        {
                            Wrong_Action();
                        }
                    }
                    else
                    {
                        if (r_o == 3 && !((movez > 270) && (movez < 360 - threshold)))
                        {
                            Wrong_Action();
                        }
                        else if (r_o == 1 && !((movez > threshold) && (movez < 90)))
                        {
                            Wrong_Action();
                        }
                    }
                    if (fb_flip == 0)
                    {
                        if (r_o == 0 && !((movex > threshold) && (movex < 90)))
                        {
                            Wrong_Action();
                        }
                        else if (r_o == 2 && !((movex > 270) && (movex < 360 - threshold)))
                        {
                            Wrong_Action();
                        }
                    }
                    else
                    {
                        if (r_o == 2 && !((movex > threshold) && (movex < 90)))
                        {
                            Wrong_Action();
                        }
                        else if (r_o == 0 && !((movex > 270) && (movex < 360 - threshold)))
                        {
                            Wrong_Action();
                        }
                    }
                }

                if (ctr > 0 && info_mode == 0 && info_mode1 == 0)
                {
                    score        = score + difficulty;
                    T_Score.text = "Score : " + score;
                    Cont_Correct++;
                    playaudio(15);
                    info_mode1 = 1;

                    if (Cont_Correct == 5)
                    {
                        Cont_Correct = 0;
                        Lives++;
                        playaudio(12);
                        T_Lives.text = "Lives : " + Lives;
                        //info_mode1=1;
                    }
                }
                info_mode = info_mode1;

                // Change level after every 5 steps
                if (GameMode != 0 && ctr == 5 && info_mode == 0)
                {
                    difficulty++;
                    T_FBStatus.text = " ";
                    T_LRStatus.text = " ";
                    T_Hint.text     = "Press 'h' for hint";
                    Cont_Correct    = 0;
                    reaction_time   = reaction_time * (0.9);
                    if (difficulty == 16)
                    {
                        playaudio(10);
                    }
                    else
                    {
                        r1 = Random.Range(1, 4);                                // 1:LR_Flip, 2:FB_Flip, 3:Both
                        if (difficulty <= 5)
                        {
                            while (r1 == 3)
                            {
                                r1 = Random.Range(1, 4);
                            }
                        }
                        playaudio(5 + r1);
                        ctr = 0;
                    }
                    info_mode         = 1;
                    T_Difficulty.text = "Difficulty : " + difficulty;
                }

                timeold = Time.time;
                if (GameMode != 0 && info_mode == 0)
                {
                    //Debug.Log("Before Playing : i = "+ i);
                    r = Random.Range(0, 4);
                    while (r == r_o)
                    {
                        r = Random.Range(0, 4);
                    }
                    r_o = r;
                    playaudio(r);
                    ctr++;
                }
            }
        }
    }