Ejemplo n.º 1
0
    private DirectionalInputs GetDirectionalInputs(PlayerIndex playerIndex, PlayerInput input, int currentFrame)
    {
        var keyboardDirection = KeysToDirectionalInput(pressedKeys[playerIndex]);

        var(leftStick, rightStick) = GetThumbSticks(playerIndex);
        var mousePosition = Mouse.GetState().Position;
        var mouseAim      = playerIndex == PlayerIndex.One && mousePosition != previousMousePosition
            ? (camera.ScreenToWorld(mousePosition.X, mousePosition.Y) - transformMapper.Get(playerEntitiesByIndex[playerIndex]).Position).NormalizedOrZero()
            : Vector2.Zero;

        var acceleration = keyboardDirection != default ? keyboardDirection : leftStick.NormalizedOrZero();
        var aim          = mouseAim != default ? mouseAim : rightStick.NormalizedOrZero();

        if (aim == Vector2.Zero && input.DirectionalInputsByFrame.ContainsKey(currentFrame - 1))
        {
            aim = input.DirectionalInputsByFrame[currentFrame - 1].AimDirection;
        }

        var directionalInputs = new DirectionalInputs(acceleration, aim);

        return(directionalInputs);
    }
Ejemplo n.º 2
0
        public static InputType DirectionalToInputType(DirectionalInputs dirInput)
        {
            var dirInt = (int)dirInput;

            return((InputType)dirInt);
        }