Exemplo 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();
         }
     }
 }
Exemplo n.º 2
0
    public void OnPointerUp(PointerEventData e)
    {
        isDown = false;

        if (timer < minSwipeDuration || timer > maxSwipeDuration)
        {
            return;
        }

        Vector2 diff = e.position - startPos;
        float   dist = diff.magnitude;

        if (dist < minSwipeDistance)
        {
            return;
        }

        if (Mathf.Abs(diff.x) < Mathf.Abs(diff.y))
        {
            return;
        }

        if (diff.x > 0)
        {
            SwipeRight?.Invoke();
        }
        else
        {
            SwipeLeft?.Invoke();
        }
    }
Exemplo n.º 3
0
        public void SwipeRightEvent()
        {
            var para = SwipeRightCommandParameter ?? CommandParameter;

            if (null != SwipeRightCommand)
            {
                if (SwipeRightCommand.CanExecute(para))
                {
                    SwipeRightCommand.Execute(para);
                }
            }
            else
            {
                SwipeRight?.Invoke(this, para);
            }
        }
Exemplo n.º 4
0
        public void ReleaseTouch()
        {
            IsSwiping = false;

            if (Time.time - startTime > MAX_TIME)
            {
                return;
            }

            if (Mathf.Abs(startPosition.x - endPosition.x) > MIN_HORIZONTAL_DIST)
            {
                var angle = Vector2.Angle(Vector2.left, startPosition - endPosition);
                if (angle < ANGLE_TOLERANCE)
                {
                    SwipeRight?.Invoke();
                }
                else if (180 - angle < ANGLE_TOLERANCE)
                {
                    SwipeLeft?.Invoke();
                }
            }
        }
        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);
        }
Exemplo n.º 6
0
 public virtual void OnSwipeRight()
 {
     SwipeRight?.Invoke();
 }
 public void OnSwipeRight() =>
 SwipeRight?.Invoke(this, null);
Exemplo n.º 8
0
 private void SwipeDetector_SwipeRight(float velocity, float angle)
 {
     SwipeRight.RaiseEvent(this);
 }
 private void SwipeGestureRecognizer_Swiped_1(object sender, SwipedEventArgs e)
 {
     //right
     SwipeRight?.Invoke(this, null);
 }
Exemplo n.º 10
0
 private static void InvokeSwipeRight(Vector2 delta)
 {
     SwipeRight?.Invoke(delta);
 }