void ButtonControlsXInput(int i)
    {
        XboxButton val = myXCIButtons[i].GetXboxButtonCode();

        if (XCI.GetButtonDown(val, xboxController))
        {
            if (s_GameManager.ShowDebug() || ShowDebug)
            {
                Debug.Log(val.ToString() + " is value of down");
            }
            myXCIButtons[i].Execute();
        }
        if (XCI.GetButtonUp(val, xboxController))
        {
            if (s_GameManager.ShowDebug() || ShowDebug)
            {
                Debug.Log(val.ToString() + " is value of up");
            }
            myXCIButtons[i].ExecuteOnUp();
        }
    }
 public virtual void Execute(float axisValue)
 {
     if (s_GameManager.ShowDebug() || myPlayer.GetMovementScript().ShowDebug)
     {
         if (myButtonName != "")
         {
             Debug.Log("Call to " + myButtonName + " positive");
         }
         else
         {
             Debug.Log("Call to " + xboxButton.ToString() + " positive");
         }
     }
 }
    void OnButton(int joyNumber, XboxButton btn)
    {
        print ("Joy " + joyNumber + " Pressed " + btn.ToString());

        if(_joyNumber != joyNumber)
            return;

        if(onButtonDown != null)
        {
            onButtonDown(btn);
        }

        if(!GetComponent<SpriteRenderer>().enabled && btn == XboxButton.buttonStart)
        {
            GetComponent<PlayerLogic>().enabled = true;
            GetComponent<PlayerView>().enabled = true;
            GetComponent<SpriteRenderer>().enabled = true;
            GetComponent<Collider>().enabled = true;
            gameObject.SetActive(true);
            for(int i = 0; i < transform.childCount; i++)
                transform.GetChild(i).gameObject.SetActive(true);
        }
    }
Exemplo n.º 4
0
    void OnButton(int joyNumber, XboxButton btn)
    {
        if(Time.timeSinceLevelLoad > 12)
        {

            print ("APertando " + btn.ToString());
            if(btn == XboxButton.buttonA)
            {
                Application.LoadLevel("gameplay");

            }
            else if(btn == XboxButton.buttonB)
            {
                Application.LoadLevel("how to");

            }
            else if(btn == XboxButton.buttonX)
            {
                Application.LoadLevel("credits");

            }
        }
    }
 void ButtonChanged()
 {
     image.sprite = Resources.Load <Sprite>($"Xbox One/XboxOne_{_button.ToString()}");
 }
        private static bool GetGamepadButtonHeld(GamePadState state, XboxButton btn)
        {
            switch (btn)
            {
            case XboxButton.A:
                return(state.Buttons.A == ButtonState.Pressed);

            case XboxButton.B:
                return(state.Buttons.B == ButtonState.Pressed);

            case XboxButton.Back:
                return(state.Buttons.Back == ButtonState.Pressed);

            case XboxButton.DPadDown:
                return(state.DPad.Down == ButtonState.Pressed);

            case XboxButton.DPadLeft:
                return(state.DPad.Left == ButtonState.Pressed);

            case XboxButton.DPadRight:
                return(state.DPad.Right == ButtonState.Pressed);

            case XboxButton.DPadUp:
                return(state.DPad.Up == ButtonState.Pressed);

            case XboxButton.LB:
                return(state.Buttons.LeftShoulder == ButtonState.Pressed);

            case XboxButton.LeftStick:
                return(state.Buttons.LeftStick == ButtonState.Pressed);

            case XboxButton.LeftTrigger:
                return(Mathf.Abs(state.Triggers.Left) > triggerDeadZone);

            case XboxButton.RB:
                return(state.Buttons.RightShoulder == ButtonState.Pressed);

            case XboxButton.RightStick:
                return(state.Buttons.RightStick == ButtonState.Pressed);

            case XboxButton.RightTrigger:
                return(Mathf.Abs(state.Triggers.Right) > triggerDeadZone);

            case XboxButton.Start:
                return(state.Buttons.Start == ButtonState.Pressed);

            case XboxButton.X:
                return(state.Buttons.X == ButtonState.Pressed);

            case XboxButton.Y:
                return(state.Buttons.Y == ButtonState.Pressed);

            case XboxButton.None:
                return(false);
            }
            throw new InvalidOperationException("Attempted to read unhandled gamepad button " + btn.ToString());
        }
 public XCIButton(s_Player p, XboxButton buttonValue) : base(p, (KeyCode)0)
 {
     xboxButton   = buttonValue;
     myButtonName = buttonValue.ToString();
 }