private void HandleButtonEvents(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
    {
        if (enabled && NGUITools.GetActive(gameObject))
        {
            // Ignoring P to allow any player to use the menu
            if (bs.Equals(OuyaSDK.InputAction.KeyDown))
            {
                switch (b)
                {
                case OuyaSDK.KeyEnum.BUTTON_DPAD_UP:
                    OnKey(KeyCode.UpArrow);
                    break;

                case OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN:
                    OnKey(KeyCode.DownArrow);
                    break;

                case OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT:
                    OnKey(KeyCode.LeftArrow);
                    break;

                case OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT:
                    OnKey(KeyCode.RightArrow);
                    break;
                }
            }

            if (b == activateButton && gameObject == UICamera.selectedObject)
            {
                SendMessage("OnPress", bs.Equals(OuyaSDK.InputAction.KeyDown), SendMessageOptions.DontRequireReceiver);
            }
        }
    }
예제 #2
0
 private void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
 {
     if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown))
     {
         //we cna use this if we want event-based inputs instead
     }
 }
예제 #3
0
    void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
    {
        if (!player.Equals(p))
        {
            return;
        }

        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            this.animation.Play("attack");
            Debug.Log("Button O Down Event was triggered on Player" + player);
        }

        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            Debug.Log("Button O Up Event was triggered on Player" + player);
        }

        //BATTLE STANCE:
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            if (!isBattleStance)
            {
                //Set Battle stance.
                this.animation.Play("waitingforbattle");
                isBattleStance = true;
            }
            else
            {
                if (this.animation.IsPlaying("waitingforbattle"))
                {
                    this.animation.Play("idle");
                    isBattleStance = false;
                }
            }
        }

        //DANCE:
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            this.animation.Play("dance");
        }


        //FAKE Death:
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            this.animation.Play("die");
        }
    }
예제 #4
0
    //Handles Button Events.
    private void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
    {
        //Debug.Log(string.Format("Player:{0} | Button:{1} | InputAction:{2}", p, b, bs));
        m_inputAction = bs;
        m_keyEnum     = b;

        //If this event was not meant for us then do not handle it.
        if (!player.Equals(p))
        {
            return;
        }

        //NOTE: This Button event handler only handles events for Player 1, because of the above statement.

        #region BUTTONS O - A
        //Check O button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonO, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonO, false, true);
        }

        //Check U button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonU, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonU, false, true);
        }

        //Check Y button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonY, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonY, false, true);
        }

        //Check A button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonA, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonA, false, true);
        }

        //Check L3 button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_L3) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererAxisLeft, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_L3) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererAxisLeft, false, true);
        }

        //Check R3 button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_R3) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererAxisRight, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_R3) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererAxisRight, false, true);
        }
        #endregion

        #region Bumpers
        //Check LB button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LB) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererLB, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LB) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererLB, false, true);
        }

        //Check RB button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RB) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererRB, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RB) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererRB, false, true);
        }
        #endregion

        #region triggers
        //Check LT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererLT, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererLT, false, true);
        }

        //Check RT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererRT, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererRT, false, true);
        }
        #endregion

        #region DPAD
        //Check DPAD UP button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_UP) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadUp, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_UP) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadUp, false, true);
        }

        //Check DPAD DOWN button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadDown, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadDown, false, true);
        }

        //Check DPAD LEFT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadLeft, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadLeft, false, true);
        }

        //Check DPAD RIGHT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadRight, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadRight, false, true);
        }
        #endregion
    }
예제 #5
0
    //Handles Button Events.
    private void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs)
    {
        //Debug.Log(string.Format("Player:{0} | Button:{1} | InputAction:{2}", p, b, bs));
        m_inputAction = bs;
        m_keyEnum = b;

        //If this event was not meant for us then do not handle it.
        if (!player.Equals(p)) { return; }

        //NOTE: This Button event handler only handles events for Player 1, because of the above statement.

        #region BUTTONS O - A
        //Check O button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonO, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonO, false, true);
        }

        //Check U button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonU, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonU, false, true);
        }

        //Check Y button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonY, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonY, false, true);
        }

        //Check A button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererButtonA, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererButtonA, false, true);
        }

        //Check L3 button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_L3) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererAxisLeft, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_L3) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererAxisLeft, false, true);
        }

        //Check R3 button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_R3) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererAxisRight, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_R3) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererAxisRight, false, true);
        }
        #endregion

        #region Bumpers
        //Check LB button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LB) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererLB, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LB) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererLB, false, true);
        }

        //Check RB button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RB) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererRB, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RB) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererRB, false, true);
        }
        #endregion

        #region triggers
        //Check LT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererLT, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_LT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererLT, false, true);
        }

        //Check RT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererRT, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_RT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererRT, false, true);
        }
        #endregion

        #region DPAD
        //Check DPAD UP button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_UP) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadUp, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_UP) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadUp, false, true);
        }

        //Check DPAD DOWN button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadDown, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadDown, false, true);
        }

        //Check DPAD LEFT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadLeft, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadLeft, false, true);
        }

        //Check DPAD RIGHT button for down state
        if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT) && bs.Equals(OuyaSDK.InputAction.KeyDown))
        {
            UpdateHighlight(RendererDpadRight, true, true);
        }
        else if (b.Equals(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT) && bs.Equals(OuyaSDK.InputAction.KeyUp))
        {
            UpdateHighlight(RendererDpadRight, false, true);
        }
        #endregion
    }
예제 #6
0
 //Call this event ( trigger )
 public static void buttonPressEvent(OuyaSDK.OuyaPlayer player, OuyaSDK.KeyEnum button, OuyaSDK.InputAction buttonState)
 {
     if (ButtonsEvent != null)
     {
         ButtonsEvent(player, button, buttonState);
     }
 }