Пример #1
0
 void IInputHandler.HandleInput(InputActionEvent action)
 {
     if (_playerInArea && action.IsInteract())
     {
         _trigger.Fire();
     }
 }
    public void HandleInput(InputActionEvent action)
    {
        if (action.Type == InputActionType.Down)
        {
            if (action.Action == MyGameInputActions.Jump)
            {
                Jump();
            }
        }

        if (action.Type == InputActionType.Held && !_blocked)
        {
            if (action.Action == InputMap.Left)
            {
                _facingDirection = Vector2.left;
            }
            else if (action.Action == InputMap.Right)
            {
                _facingDirection = Vector2.right;
            }
        }

        if (action.Type == InputActionType.Up)
        {
            if (action.Action == InputMap.Left || action.Action == InputMap.Right)
            {
                _facingDirection = Vector2.zero;
            }
        }
    }
Пример #3
0
    void IInputHandler.HandleInput(InputActionEvent action)
    {
        if (!InputEnabled)
        {
            return;
        }

        _playerController.HandleInput(action);
    }
Пример #4
0
    public override void HandleInput(InputActionEvent action)
    {
        navigation.HandleInput(action);
        holdDropBehaviour.HandleInput(action);

        if (action.Action == InputAction.Drop && action.Type == InputActionType.Down)
        {
            DropItem();
        }
    }
Пример #5
0
    void IInputHandler.HandleInput(InputActionEvent action)
    {
        if (Game.GameState.State == State.Paused)
        {
            return;
        }

        if (action.Action == InputAction.Interact)
        {
            OnInteract(action.Type);
        }
    }
Пример #6
0
        /// <summary>
        /// Bind an input action to a function that handles the input event
        /// </summary>
        /// <param name="inputActionId">The id of the input action binding</param>
        /// <param name="eventHandler">The function that will handle this input action event</param>
        public void BindAction(string inputActionId, InputActionEvent eventHandler)
        {
            if (Engine.Get.Settings.Input.ActionBindings.Count(x => x.Id == inputActionId) == 0)
            {
                throw new GlaivesException($"No action binding exists in input settings with id '{inputActionId}'");
            }

            if (InputActionEvents.ContainsKey(inputActionId))
            {
                throw new GlaivesException($"Failed to bind '{inputActionId}', can not bind to the same input action multiple times for the same actor");
            }
            InputActionEvents.Add(inputActionId, eventHandler);
        }
Пример #7
0
    void IInputHandler.HandleInput(InputActionEvent action)
    {
        if (action.Type == InputActionType.Axis)
        {
            if (action.Action == InputMap.Horizontal)
            {
                movePosition.x += action.Delta * _sensitivity;
            }

            if (action.Action == InputMap.Vertical)
            {
                movePosition.y += action.Delta * _sensitivity;
            }
        }
    }
    public override void HandleInput(InputActionEvent action)
    {
        if (action.Type == InputActionType.Down)
        {
            if (action.Action == InputMap.Up)
            {
                _buttons.Prev();
            }

            if (action.Action == InputMap.Down)
            {
                _buttons.Next();
            }
        }
    }
Пример #9
0
    void IMonoLateUpdateReceiver.OnLateUpdate()
    {
        foreach (var kvp in bindings)
        {
            if (Input.anyKey)
            {
                if (Input.GetKeyDown(kvp.Value))
                {
                    var e = new InputActionEvent(kvp.Key, InputActionType.Down);
                    FireTrigger(e);
                }

                if (Input.GetKey(kvp.Value))
                {
                    var e = new InputActionEvent(kvp.Key, InputActionType.Held);
                    FireTrigger(e);
                }
            }

            if (Input.GetKeyUp(kvp.Value))
            {
                var e = new InputActionEvent(kvp.Key, InputActionType.Up);
                FireTrigger(e);
            }
        }

        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            FireTrigger(new InputActionEvent(InputAction.ScrollUp, InputActionType.Down));
        }

        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            FireTrigger(new InputActionEvent(InputAction.ScrollDown, InputActionType.Down));
        }

        if (Input.GetMouseButtonDown(0))
        {
            FireTrigger(new InputActionEvent(InputAction.MouseLeft, InputActionType.Down));
        }

        if (Input.GetMouseButtonDown(1))
        {
            FireTrigger(new InputActionEvent(InputAction.MouseRight, InputActionType.Down));
        }
    }
Пример #10
0
        public void HandleInput(InputActionEvent action)
        {
            if (lists.Count == 0)
            {
                return;
            }

            holdBehaviourDown.HandleInput(action);
            holdBehaviourUp.HandleInput(action);

            if (action.Type == InputActionType.Down)
            {
                switch (action.Action)
                {
                case InputMap.Up:
                    lists[index].MovePrev();
                    break;

                case InputMap.Down:
                    lists[index].MoveNext();
                    break;

                case InputMap.ScrollUp:
                    lists[index].MovePrev();
                    break;

                case InputMap.ScrollDown:
                    lists[index].MoveNext();
                    break;

                case InputMap.Right:
                    FocusNext();
                    break;

                case InputMap.Left:
                    FocusPrev();
                    break;

                default:
                    break;
                }
            }
        }
Пример #11
0
    void IInputHandler.HandleInput(InputActionEvent action)
    {
        if (!InputEnabled)
        {
            return;
        }

        _menu.CurrentMenu.HandleInput(action);

        if (action.Type == InputActionType.Down)
        {
            if (action.Action == InputAction.LeftBumper)
            {
                _menu.CyclicalList.MovePrev();
            }

            if (action.Action == InputAction.RightBumper)
            {
                _menu.CyclicalList.MoveNext();
            }
        }
    }
Пример #12
0
    void IInputHandler.HandleInput(InputActionEvent action)
    {
        // Toggle menu open state.
        if (action.Action == InputAction.Inventory && action.Type == InputActionType.Down)
        {
            if (menuOpen)
            {
                menuOpen = false;
                if (MenuClosed != null)
                    MenuClosed();
            }
            else
            {
                menuOpen = true;
                if (MenuOpened != null)
                    MenuOpened();
            }

            menu.SetVisibility(menuOpen);
            Hud.gameObject.SetActive(!menuOpen);
        }
    }
Пример #13
0
 public virtual void HandleInput(InputActionEvent action)
 {
 }
 public static bool IsHeldInteract(this InputActionEvent action)
 {
     return(action.Action == MyGameInputActions.Interact && action.Type == InputActionType.Held);
 }