Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 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);
        }
        public override bool OnJsAlert(WebView view, string url, string message, JsResult result)
        {
            Logger.Log("JS", message);

            if (message.StartsWith("page count: "))
            {
                int pageCount = int.Parse(message.Split(": ")[1]);

                ChapterLoaded?.Invoke(pageCount);
            }

            if (message == "swipe left")
            {
                SwipeLeft?.Invoke();
            }

            if (message == "swipe right")
            {
                SwipeRight?.Invoke();
            }

            if (message == "swipe down")
            {
                SwipeDown?.Invoke();
            }

            if (message.StartsWith("word selected: "))
            {
                string word     = message.Split(": ")[1].Split('|')[0].Trim().ToLower();
                string sentence = message.Split(": ")[1].Split('|')[1].Trim();

                WordSelected?.Invoke(word, sentence);
            }

            result.Cancel();
            return(true);
        }
Ejemplo n.º 4
0
 public void OnSwipeDown()
 {
     SwipeDown?.Invoke(this, null);
 }
Ejemplo n.º 5
0
 private static void InvokeSwipeDown(Vector2 delta)
 {
     SwipeDown?.Invoke(delta);
 }