Esempio n. 1
0
    private void UpdateController()
    {
        UpdateHighlight(RendererAxisLeft, Mathf.Abs(OuyaInputManager.GetAxis("LX", player)) > 0.25f ||
                        Mathf.Abs(OuyaInputManager.GetAxis("LY", player)) > 0.25f);

        RendererAxisLeft.transform.localRotation = Quaternion.Euler(OuyaInputManager.GetAxis("LY", player) * 15, 0, OuyaInputManager.GetAxis("LX", player) * 15);

        UpdateHighlight(RendererAxisRight, Mathf.Abs(OuyaInputManager.GetAxis("RX", player)) > 0.25f ||
                        Mathf.Abs(OuyaInputManager.GetAxis("RY", player)) > 0.25f);

        RendererAxisRight.transform.localRotation = Quaternion.Euler(OuyaInputManager.GetAxis("RY", player) * 15, 0, OuyaInputManager.GetAxis("RX", player) * 15);

        if (OuyaInputManager.GetButtonDown("L3", player))
        {
            RendererAxisLeft.transform.localPosition = Vector3.Lerp(RendererAxisLeft.transform.localPosition,
                                                                    new Vector3(5.503977f, 0.75f, -3.344945f), Time.fixedDeltaTime);
        }
        else
        {
            RendererAxisLeft.transform.localPosition = Vector3.Lerp(RendererAxisLeft.transform.localPosition,
                                                                    new Vector3(5.503977f, 1.127527f, -3.344945f), Time.fixedDeltaTime);
        }

        if (OuyaInputManager.GetButtonDown("R3", player))
        {
            RendererAxisRight.transform.localPosition = Vector3.Lerp(RendererAxisRight.transform.localPosition,
                                                                     new Vector3(-2.707688f, 0.75f, -1.354063f), Time.fixedDeltaTime);
        }
        else
        {
            RendererAxisRight.transform.localPosition = Vector3.Lerp(RendererAxisRight.transform.localPosition,
                                                                     new Vector3(-2.707688f, 1.11295f, -1.354063f), Time.fixedDeltaTime);
        }
    }
Esempio n. 2
0
 public static bool GetRight()
 {
     return
         (Input.GetKey(KeyCode.RightArrow) ||
          Input.GetKey(KeyCode.D) ||
          OuyaInputManager.GetButton("DPR", OuyaSDK.OuyaPlayer.player2) ||
          OuyaInputManager.GetAxis("LX", OuyaSDK.OuyaPlayer.player2) > 0.25f);
 }
Esempio n. 3
0
 public static bool GetLeft()
 {
     return
         (Input.GetKey(KeyCode.LeftArrow) ||
          Input.GetKey(KeyCode.A) ||
          OuyaInputManager.GetButton("DPL", OuyaSDK.OuyaPlayer.player2) ||
          OuyaInputManager.GetAxis("LX", OuyaSDK.OuyaPlayer.player2) < -0.25f);
 }
Esempio n. 4
0
 public static bool GetUp()
 {
     return
         (Input.GetKey(KeyCode.UpArrow) ||
          Input.GetKey(KeyCode.W) ||
          OuyaInputManager.GetButton("DPU", OuyaSDK.OuyaPlayer.player2) ||
          OuyaInputManager.GetAxis("LY", OuyaSDK.OuyaPlayer.player2) > 0.25f);
 }
Esempio n. 5
0
    // Using this format:
    //
    //   W      I
    // A S D  J K L
    //

    // Ouya:
    //   Y
    // U   A
    //   O
    //

    // ouya parameter string values
    // SYS, DPC, DPD, DPL, DPR, DPU, O, U, Y, A, LT, RT, LB, RB, L3, R3

    //ouya axes
    // Left Analog: LY LX,  Right Analog: RY RX,  Trigger: RT, LT

    public static bool GetDown()
    {
        return
            (Input.GetKey(KeyCode.DownArrow) ||
             Input.GetKey(KeyCode.S) ||
             OuyaInputManager.GetButton("DPD", OuyaSDK.OuyaPlayer.player2) ||
             OuyaInputManager.GetAxis("LY", OuyaSDK.OuyaPlayer.player2) < -0.25f);
    }
    void Update()
    {
        if (joystickCanTrigger && enabled && NGUITools.GetActive(gameObject))
        {
            float greatestX = 0.0f;
            float greatestY = 0.0f;
            float leastX    = 0.0f;
            float leastY    = 0.0f;

            //foreach (OuyaSDK.OuyaPlayer player in Enum.GetValues(typeof(OuyaSDK.OuyaPlayer))) // TODO: Use once input lag is fixed
            for (int i = 1; i <= 4; ++i) // HACK: check a hard-coded number of players
            {
                OuyaSDK.OuyaPlayer player = (OuyaSDK.OuyaPlayer)i;

                float joystickX = OuyaInputManager.GetAxis("LX", player);
                float joystickY = OuyaInputManager.GetAxis("LY", player);

                greatestX = Math.Max(joystickX, greatestX);
                greatestY = Math.Max(joystickY, greatestY);
                leastX    = Math.Min(joystickX, leastX);
                leastY    = Math.Min(joystickY, leastY);
            }

            if (greatestX > JoystickThreshold)
            {
                StartJoystickResetTimer();
                OnKey(KeyCode.RightArrow);
            }
            if (greatestY > JoystickThreshold)
            {
                StartJoystickResetTimer();
                OnKey(KeyCode.UpArrow);
            }
            if (leastX < -JoystickThreshold)
            {
                StartJoystickResetTimer();
                OnKey(KeyCode.LeftArrow);
            }
            if (leastY < -JoystickThreshold)
            {
                StartJoystickResetTimer();
                OnKey(KeyCode.DownArrow);
            }
        }
    }
Esempio n. 7
0
    void Update()
    {
        //Get Joystick points and calculate deadzone.
        Vector2 point = convertRawJoystickCoordinates(OuyaInputManager.GetAxis("LX", player), OuyaInputManager.GetAxis("LY", player), .25f);

        //Debug.Log(string.Format("Player:{0}, Axis:{1}",player,point));

        //Rotate character to where it is looking.
        transform.Rotate(0f, point.x * turnSpeed * Time.deltaTime, 0f);

        //only move if we are grounded.
        if (controller.isGrounded)
        {
            //get the move direction from the controller axis;
            moveDirection = transform.forward * point.y;

            //Set the speed
            moveDirection *= speed;
        }

        //Apply any gravity factors
        moveDirection.y -= gravity * Time.deltaTime;

        //Move the character;
        controller.Move(moveDirection * Time.deltaTime);

        //Handle animation if we are moving.
        if (point.x != 0f && point.y != 0f)
        {
            //If axis is not 0 then play run animation.
            this.animation.Play("run");
        }

        //if no animation is playing, then play the idle animation.
        if (!this.animation.isPlaying)
        {
            string anim = "idle";
            if (isBattleStance)
            {
                anim = "waitingforbattle";
            }
            this.animation.Play(anim);
        }
    }
Esempio n. 8
0
    private void OnGUI()
    {
        try
        {
            // UpdateCamera();
            OuyaNGUIHandler nguiHandler = GameObject.Find("_NGUIHandler").GetComponent <OuyaNGUIHandler>();
            if (nguiHandler != null)
            {
                string[] joystickNames = Input.GetJoystickNames();
                //foreach (string joystick in Input.GetJoystickNames())
                for (int i = 0; i < joystickNames.Length && i < 4; i++)
                {
                    if (i == 1)
                    {
                        nguiHandler.controller1.text = joystickNames[i];
                    }
                    if (i == 2)
                    {
                        nguiHandler.controller1.text = joystickNames[i];
                    }
                    if (i == 3)
                    {
                        nguiHandler.controller1.text = joystickNames[i];
                    }
                    if (i == 4)
                    {
                        nguiHandler.controller1.text = joystickNames[i];
                    }
                }

                nguiHandler.genericEvent.text  = m_inputAction + " : " + m_keyEnum;
                nguiHandler.joystickLeft.text  = string.Format("{0},{1}", OuyaInputManager.GetAxis("LX", player), OuyaInputManager.GetAxis("LY", player));
                nguiHandler.joystickRight.text = string.Format("{0},{1}", OuyaInputManager.GetAxis("RX", player), OuyaInputManager.GetAxis("RY", player));
                nguiHandler.trigger.text       = string.Format("{0},{1}", OuyaInputManager.GetAxis("LT", player), OuyaInputManager.GetAxis("RT", player));
                nguiHandler.rawOut.text        = OuyaGameObject.InputData;
            }
        }
        catch (System.Exception)
        {
        }
    }