Пример #1
0
 private void MovePlayer(Vector2 deltaDrag)
 {
     if (Mathf.Abs(deltaDrag.x) > Mathf.Abs(deltaDrag.y))
     {
         //// Horizontal
         if (deltaDrag.x > 0)
         {
             // Right
             SwipeRight.Invoke();
         }
         else
         {
             // Left
             SwipeLeft.Invoke();
         }
     }
     else
     {
         //// Vertical
         if (deltaDrag.y > 0)
         {
             // Up
             SwipeUp.Invoke();
         }
         else
         {
             // Down
             SwipeDown.Invoke();
         }
     }
 }
Пример #2
0
        public bool OnTouch(View v, MotionEvent e)
        {
            var checkheight = v.Height <= 0 ? _defaultCheckHeight : v.Height * 0.04;

            if (e.ActionMasked == MotionEventActions.Move)
            {
                if (FirstYPrecision != 0 && SecondYPrecision == 0)
                {
                    SecondYPrecision = e.GetY();
                }
                if (FirstYPrecision == 0)
                {
                    FirstYPrecision = e.GetY();;
                }
            }
            if (e.ActionMasked == MotionEventActions.Up)
            {
                if (FirstYPrecision != 0 && SecondYPrecision != 0 && (FirstYPrecision - SecondYPrecision) > checkheight)
                {
                    try
                    {
                        SwipeUp.Invoke(null, null);
                    }
                    catch (Exception ex) { Console.WriteLine("SwipeUp Exeption" + ex.Message); }
                }
                if (FirstYPrecision != 0 && SecondYPrecision != 0 && (SecondYPrecision - FirstYPrecision) > 0)
                {
                    try
                    {
                        SwipeDown.Invoke(null, null);
                    }
                    catch (Exception ex) { Console.WriteLine("SwipeDown Exeption" + ex.Message); }
                }
                FirstYPrecision  = 0;
                SecondYPrecision = 0;
            }

            return(false);
        }
Пример #3
0
 // invokers methods
 private static void InvokeSwipeUp(Vector2 delta)
 {
     SwipeUp?.Invoke(delta);
 }