Exemple #1
0
 void OnGUI()
 {
     if (GUILayout.Button(String.Format("Gyro {0}", GyroInput.getInstance().getTilt())))
     {
         Debug.Log("Hello!");
     }
 }
Exemple #2
0
 public static GyroInput getInstance()
 {
     if (GyroInput.instance == null)
     {
         GyroInput.instance = new GyroInput();
     }
     return(instance);
 }
Exemple #3
0
    // Use this for initialization
    IEnumerator Start()
    {
        Init();
        GyroInput.inst.AddNodListener(CorrecteUIPostion);
        yield return(new WaitForSeconds(0.2f));

        GyroInput.CorrecteUIPostion(canvas);
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        DontLeaveEarth();
        if (playerState == PlayerState.None)
        {
            if (Input.GetMouseButtonDown(0))
            {
                StartMoving();
            }
        }
        if (playerState == PlayerState.StartStairs)
        {
            transform.Translate(new Vector3(0, 1, 0) * speed * Time.deltaTime);


            timer      += Time.deltaTime;
            trailTimer += Time.deltaTime;

            if (trailTimer > timeToSpawnTrail)
            {
                SpawnTrail();
                trailTimer = 0;
            }

            if (timer > timeToNextState)
            {
                MoveDone();
            }
        }
        if (playerState == PlayerState.Listening)
        {
            timer += Time.deltaTime;
            Debug.Log(timer + ":" + timeToNextState);
            if (timer > timeToNextState)
            {
                Debug.Log("Listen Done");

                VA_AudioSource[] sources = GameObject.FindObjectsOfType <VA_AudioSource>();
                for (int i = 0; i < sources.Length; i++)
                {
                    sources[i].BaseVolume *= 4f;
                }

                playerState = PlayerState.None;
                HideScreen();
            }
        }
        rotation = rotation * rotationSpeed;
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, ClampAngle(rotation * range, -range, range));

        float horizontal = GyroInput.getInstance().getTilt();

        horizontal = Mathf.Clamp(horizontal, -1, 1);

        UpdateRotation(horizontal);
    }
Exemple #5
0
    /// <summary>
    /// Handles the remote rotation input.
    /// </summary>
    private void handleQuaternion(GyroInput input)
    {
        gyroQuaternion = input.Data;

        // save the initial rotation
        if (gyroInitialRotation == null)
        {
            gyroInitialRotation = gyroQuaternion;
        }
    }
 void Start()
 {
     if (_instance != null)
     {
         Destroy(this.gameObject);
         return;
     }
     _instance       = this;
     gyroInput       = GetComponent <GyroInput> ();
     swipeController = GetComponent <SwipeController> ();
     DontDestroyOnLoad(gameObject);
 }
Exemple #7
0
    /// <summary>
    /// Convert a byte array representing a quaternion into a <see cref="GyroInput"/>.
    /// The order of the quaternion numbers is changed, because the Android's orientation is not compatible with Unity.
    /// </summary>
    private static GyroInput readQuaternion(byte[] quaternion)
    {
        byte[] temp = new byte[4];

        Array.Copy(quaternion, 1, temp, 0, 4);
        float x = NetworkToHostOrderFloat(temp);

        Array.Copy(quaternion, 5, temp, 0, 4);
        float y = NetworkToHostOrderFloat(temp);

        Array.Copy(quaternion, 9, temp, 0, 4);
        float z = NetworkToHostOrderFloat(temp);

        Array.Copy(quaternion, 13, temp, 0, 4);
        float w = NetworkToHostOrderFloat(temp);

        GyroInput input = new GyroInput();

        input.Data = new float[] { -y, x, -z, w };
        return(input);
    }
Exemple #8
0
 void CorrecteUIPostion()
 {
     GyroInput.CorrecteUIPostion(canvas);
 }
Exemple #9
0
 void Awake()
 {
     instance           = this;
     Input.gyro.enabled = true;
 }