Beispiel #1
0
        public void Update(object sender, UpdateData data)
        {
            MultiState
                newState = new MultiState(),
                oldState = _inputState;

            List <GameInputs> gameInputs = Util.GetValues <GameInputs>();

            for (int i = 0; i < gameInputs.Count; ++i)
            {
                GameInputs
                    gameInput = gameInputs[i];

                if (!_inputMap.Keys.Contains(gameInput))
                {
                    continue;
                }

                MultiInput input = _inputMap[gameInput];

                bool
                    isDown  = newState.IsDown(input),
                    wasDown = oldState.IsDown(input);

                if (isDown && !wasDown)
                {
                    if (PressedEvent != null)
                    {
                        PressedEvent(this, new InputData(gameInput));
                    }
                }
                else if (!isDown && wasDown)
                {
                    if (ReleasedEvent != null)
                    {
                        ReleasedEvent(this, new InputData(gameInput));
                    }
                }

                if (isDown)
                {
                    if (HeldEvent != null)
                    {
                        HeldEvent(this, new InputData(gameInput));
                    }
                }
            }

            _inputState = newState;
        }
Beispiel #2
0
        public bool IsUp(MultiInput input)
        {
            switch (input.Type)
            {
            case InputType.Key:

                return(_keyboardState.IsKeyUp(input.Key));

            case InputType.MouseButton:

                return(_mouseButtonState.IsButtonUp(input.MouseButton));

            case InputType.GamePadButton:

                return(_gamePadState.IsButtonUp(input.GamePadButton));
            }

            return(false);
        }
Beispiel #3
0
        public bool IsUp(MultiInput input)
        {
            switch (input.Type)
            {
                case InputType.Key:

                    return _keyboardState.IsKeyUp(input.Key);

                case InputType.MouseButton:

                    return _mouseButtonState.IsButtonUp(input.MouseButton);

                case InputType.GamePadButton:

                    return _gamePadState.IsButtonUp(input.GamePadButton);

            }

            return false;
        }