Пример #1
0
        /// <summary>
        /// Invokes actions of swiping with the given arguments and dependent on the direction of the swipe.
        /// </summary>
        /// <param name="args">Input arguments of the evaluated swipe.</param>
        /// <param name="direction">Direction of the evaluated swipe.</param>
        private static void InvokeSwipeActions(IVectorMovementInputArgs args, SwipeDirection direction)
        {
            switch (direction)
            {
            case SwipeDirection.LEFT:
                OnLeftSwipeDetected?.Invoke();
                MobileInput.OnSwipeLeft?.Invoke();
                break;

            case SwipeDirection.RIGHT:
                OnRightSwipeDetected?.Invoke();
                MobileInput.OnSwipeRight?.Invoke();
                break;

            case SwipeDirection.UP:
                OnUpSwipeDetected?.Invoke();
                MobileInput.OnSwipeUp?.Invoke();
                break;

            case SwipeDirection.DOWN:
                OnDownSwipeDetected?.Invoke();
                MobileInput.OnSwipeDown?.Invoke();
                break;

            case SwipeDirection.NONE:
            default:
                return;
            }

            OnSwipeEnded?.Invoke(args);
        }
 /// <summary>
 /// Gets direction of the vector input.
 /// </summary>
 /// <param name="args">Arguments of the input event.</param>
 /// <returns>Direction of the input.</returns>
 public static Vector2 GetDirection(IVectorMovementInputArgs args) => args.MovementVector;
 /// <summary>
 /// Gets position at the middle of the vector input.
 /// </summary>
 /// <param name="args">Arguments of the input event.</param>
 /// <returns>Focus point of the input.</returns>
 public static Vector2 GetFocusPoint(IVectorMovementInputArgs args) => args.StartPos + args.MovementVector * (GetMagnitude(args) / 2.0f);
 /// <summary>
 /// Gets magnitude of the vector input.
 /// </summary>
 /// <param name="args">Arguments of the input event.</param>
 /// <returns>Magnitude of the input.</returns>
 public static float GetMagnitude(IVectorMovementInputArgs args) => args.MovementVector.magnitude;
Пример #5
0
 /// <summary>
 /// Invokes action of an ongoing tilt with the given tilt movement parameters.
 /// </summary>
 /// <param name="tiltMovement">Information about the ongoing tilt movement.</param>
 private static void InvokeOngoingTiltAction(IVectorMovementInputArgs tiltMovement) => OnOngoingTilt?.Invoke(tiltMovement);
Пример #6
0
        /// <summary>
        /// Invoke ongoing tilt actions dependent on the given direction.
        /// </summary>
        /// <param name="direction">Direction of the tilt</param>
        /// <param name="tiltMovement">Current movement of the device.</param>
        private static void InvokeOngoingTiltDirectionAction(TiltDirection direction, IVectorMovementInputArgs tiltMovement)
        {
            switch (direction)
            {
            case TiltDirection.RIGHT:
                OnOngoingTiltRight?.Invoke(tiltMovement);
                break;

            case TiltDirection.LEFT:
                OnOngoingTiltLeft?.Invoke(tiltMovement);
                break;

            case TiltDirection.FORWARD:
                OnOngoingTiltForward?.Invoke(tiltMovement);
                break;

            case TiltDirection.BACKWARD:
                OnOngoingTiltBackward?.Invoke(tiltMovement);
                break;

            case TiltDirection.NONE:
            default:
                return;
            }
        }