bool GetKeyUp(ActionKeyCode key)
 {
     if ((int)key > 400)
     {
         Debug.LogError("Not A Key!");
         return(false);
     }
     return(Input.GetKeyUp((KeyCode)((int)key)));
 }
 public bool RemoveKey(ActionControl control, ActionKeyCode key)
 {
     if (actionMapping[control].Remove(key))
     {
         usedKeys.Remove(key);
         return(true);
     }
     return(false);
 }
    private void UpdateInputData()
    {
        GameInput.PlayerActions playerInput = gameInput.Player;

        InputData result = InputData.none;

        Vector2 move = playerInput.Move.ReadValue <Vector2>();

        move = Quaternion.AngleAxis(LookAtYAngle, Vector3.back) * move;

        ActionKeyCode keyCode = ActionKeyCode.None;

        if (move.x != 0)
        {
            keyCode |= move.x < 0 ? ActionKeyCode.Left : ActionKeyCode.Right;
        }

        if (move.y != 0)
        {
            keyCode |= move.y > 0 ? ActionKeyCode.Up : ActionKeyCode.Down;
        }

        if (playerInput.Move.phase == InputActionPhase.Started)
        {
            keyCode |= ActionKeyCode.Axis;
        }

        if (playerInput.Attack.triggered)
        {
            keyCode |= ActionKeyCode.Attack;
        }

        if (playerInput.Attack.phase == InputActionPhase.Started)
        {
            keyCode |= ActionKeyCode.Attacking;
        }

        if (playerInput.Skill.triggered)
        {
            keyCode |= ActionKeyCode.Skill;
        }

        if (playerInput.Dash.triggered)
        {
            keyCode |= ActionKeyCode.Dash;
        }
        result.SetKeyCode(keyCode);
        result.SetAxisFromDir(move);

        AddInput(inputTargetId, result);
        lastInput = result;
    }
 public void AddKey(int id, ActionKeyCode code)
 {
     if (id2Input.TryGetValue(id, out InputData data))
     {
         data.keyCode |= (int)code;
         id2Input[id]  = data;
     }
     else
     {
         id2Input.Add(id, new InputData()
         {
             keyCode   = (int)code,
             axisValue = 0
         });
     }
 }
    public List <ActionControl> CheckIfKeyIsUsed(ActionKeyCode key)
    {
        List <ActionControl> toReturn = new List <ActionControl>();

        if (!usedKeys.Contains(key))
        {
            toReturn.Add(ActionControl.NONE);
        }
        else
        {
            foreach (KeyValuePair <ActionControl, List <ActionKeyCode> > control in actionMapping)
            {
                foreach (ActionKeyCode actionKey in control.Value)
                {
                    if (actionKey == key)
                    {
                        toReturn.Add(control.Key);
                    }
                }
            }
        }
        return(toReturn);
    }
Beispiel #6
0
        public bool GetButton(ActionKeyCode button)
        {
            switch (button)
            {
            case ActionKeyCode.GamepadA:
                return(CurrentState.Buttons.A == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadB:
                return(CurrentState.Buttons.B == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadX:
                return(CurrentState.Buttons.X == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadY:
                return(CurrentState.Buttons.Y == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadRightTrigger:
                return(CurrentState.Triggers.Right >= TriggerSensitivity);

            case ActionKeyCode.GamepadLeftTrigger:
                return(CurrentState.Triggers.Left >= TriggerSensitivity);

            case ActionKeyCode.GamepadRightShoulder:
                return(CurrentState.Buttons.RightShoulder == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadLeftSholder:
                return(CurrentState.Buttons.LeftShoulder == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadRightStick:
                return(CurrentState.Buttons.RightStick == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadLeftStick:
                return(CurrentState.Buttons.LeftStick == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadStart:
                return(CurrentState.Buttons.Start == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadBack:
                return(CurrentState.Buttons.Back == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadGuide:
                return(CurrentState.Buttons.Guide == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadDPadUp:
                return(CurrentState.DPad.Up == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadDPadRight:
                return(CurrentState.DPad.Right == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadDPadDown:
                return(CurrentState.DPad.Down == XInputDotNetPure.ButtonState.Pressed);

            case ActionKeyCode.GamepadDpadLeft:
                return(CurrentState.DPad.Left == XInputDotNetPure.ButtonState.Pressed);

            default:
                Debug.LogError("Not a Gamepad Button");
                break;
            }
            return(false);
        }
 /// <summary>
 /// sets key binding naively
 /// </summary>
 /// <param name="control"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public void SetActionControl(ActionControl control, ActionKeyCode key)
 {
     actionMapping[control].Add(key);
     usedKeys.Add(key);
 }