Exemple #1
0
    public Vector3 directionToTargetPosition(SwipeDirections direction)
    {
        Vector3 retVector3 = Vector3.zero;

        //select new target position
        switch (direction)
        {
        case SwipeDirections.left:
            retVector3 = screenPositions.left;
            break;

        case SwipeDirections.right:
            retVector3 = screenPositions.right;
            break;

        case SwipeDirections.up:
            retVector3 = screenPositions.up;
            break;

        case SwipeDirections.down:
            retVector3 = screenPositions.down;
            break;

        case SwipeDirections.none:
        default:
            retVector3 = screenPositions.center;
            break;
        }

        return(retVector3);
    }
Exemple #2
0
    public void SetScreenTargetPosition(SwipeDirections direction)
    {
        if (direction != screenPositions.lastSetDirection)
        {
            screenPositions.targetPosition = directionToTargetPosition(direction);

            //memorize actual position and reset lerp time
            screenPositions.lerpStart          = screenPositions.lerpedPosition;
            screenPositions.movementActiveTime = 0f;
            screenPositions.lastSetDirection   = direction;
        }
        else
        {
            //the same is pressed again. Test for execution.
            //Debug.Log("Second press: " + direction.ToString());

            //set the card instantly to the target position for correct onRelease evalution
            screenPositions.lerpedPosition = screenPositions.targetPosition;
            swipeVector = screenPositions.targetPosition;
            onRelease();
            //reset position and timings for next card
            screenPositions.Reset();
            swipeVector = Vector3.zero;
        }
    }
        public override void Update()
        {
            if (!OVRInput.IsControllerConnected(Controller))
            {
                return;
            }

            //Swipe
            SwipeDirections swipeDirections = 0;

            if (OVRInput.GetDown(OVRInput.Button.DpadUp))
            {
                swipeDirections |= SwipeDirections.SwipeUp;
            }
            if (OVRInput.GetDown(OVRInput.Button.DpadDown))
            {
                swipeDirections |= SwipeDirections.SwipeDown;
            }
            if (OVRInput.GetDown(OVRInput.Button.DpadLeft))
            {
                swipeDirections |= SwipeDirections.SwipeLeft;
            }
            if (OVRInput.GetDown(OVRInput.Button.DpadRight))
            {
                swipeDirections |= SwipeDirections.SwipeRight;
            }

            if (swipeDirections == 0)
            {
                return;
            }

            Directions = swipeDirections;
            Recognize();
        }
        /// <summary>
        /// Get the vector2 to compare with a specific direction.
        /// </summary>
        protected Vector2 GetCardinalDirections(SwipeDirections swipeDirections)
        {
            switch (swipeDirections)
            {
            case SwipeDirections.None: return(default(Vector2));

            case SwipeDirections.Up: return(new Vector2(0, 1));

            case SwipeDirections.Down: return(new Vector2(0, -1));

            case SwipeDirections.Left: return(new Vector2(-1, 0));

            case SwipeDirections.Right: return(new Vector2(1, 0));

            case SwipeDirections.UpRight: return(new Vector2(1, 1));

            case SwipeDirections.UpLeft: return(new Vector2(-1, 1));

            case SwipeDirections.DownRight: return(new Vector2(1, -1));

            case SwipeDirections.DownLeft: return(new Vector2(-1, -1));

            default: return(default(Vector2));
            }
        }
Exemple #5
0
        /// <summary>
        /// Swipe from one edge of the screen to another.
        /// </summary>
        /// <param name="swipeDirection">Direction to swipe</param>
        /// <param name="duration">Duration of the swipe in milliseconds</param>
        public void Swipe(SwipeDirections swipeDirection, int duration)
        {
            if (_screenBounds == null)
            {
                SetScreenHeightAndWidth();
            }

            var middleX = _screenBounds.Width / 2;
            var middleY = _screenBounds.Height / 2;

            switch (swipeDirection)
            {
            case SwipeDirections.Left:
                Swipe(middleX, middleY, 0, middleY, duration);
                break;

            case SwipeDirections.Up:
                Swipe(middleX, middleY, middleX, 0, duration);
                break;

            case SwipeDirections.Right:
                Swipe(middleX, middleY, _screenBounds.Width, middleY, duration);
                break;

            case SwipeDirections.Down:
                Swipe(middleX, middleY, middleX, _screenBounds.Height, duration);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(swipeDirection), swipeDirection, null);
            }
        }
        public static void PropertyDetailPhotoSwipe(SwipeDirections eSwipeDirection)
        {
            int startx, starty, endx, endy;


            // Using Touch Action Classes
            TouchAction tAction = new TouchAction(AppiumDriver.Instance);

            // get the proper location of where to start to swipe from
            System.Drawing.Size size = AppiumDriver.Instance.Manage().Window.Size;

            if (eSwipeDirection == SwipeDirections.LEFT)
            {
                // get the proper location of where to start to swipe from
                startx = (int)(size.Width * 0.9) - 50;
                starty = (int)(size.Height / 3);

                endx = 50;
                endy = starty;
            }

            else   // must be right then
            {
                // get the proper location of where to start to swipe from
                startx = 10;
                starty = size.Height / 3;

                endx = (int)(size.Width * 0.9) - 50;
                endy = starty;
            }

            // perform the swipe
            //AppiumDriver.Instance.Swipe(startx, starty, endx, endy, 2000);
        }
Exemple #7
0
 public void Reset()
 {
     lerpedPosition     = Vector3.zero;
     targetPosition     = Vector3.zero;
     lerpStart          = Vector3.zero;
     lastSetDirection   = SwipeDirections.none;
     movementActiveTime = timeToMoveToCenter + 1f;
 }
Exemple #8
0
    public static void InvokeSwipe(SwipeDirections direction)
    {
        //Debug.Log($"Произошел СВАЙП: {direction}");

        if (onSwipeEvent != null)
        {
            onSwipeEvent(direction);
        }
    }
        public static void SwipeElement(IWebElement element, SwipeDirections eSwipeDirection)
        {
            int startx, starty, endx, endy;

            TouchAction tAction = new TouchAction(AppiumDriver.Instance);

            System.Drawing.Size size = element.Size;
            int locX = element.Location.X;
            int locY = element.Location.Y;

            if (eSwipeDirection == SwipeDirections.DOWN)
            {
                // get the proper location of where to start to swipe from
                startx = size.Width / 2;
                starty = 100;

                endx = startx;
                endy = (int)(size.Height * 0.8) - 100;
            }
            else if (eSwipeDirection == SwipeDirections.UP)
            {
                // get the proper location of where to start to swipe from
                startx = size.Width / 2;
                starty = 100;

                endx = startx;
                endy = (int)(size.Height * 0.8) - 100;
            }
            else if (eSwipeDirection == SwipeDirections.LEFT)
            {
                // get the proper location of where to start to swipe from
                startx = locX + (size.Width - 40);
                starty = locY + (int)(size.Height / 2);

                endx = locX + 40;
                endy = starty;
            }
            else   // must be right then
            {
                // get the proper location of where to start to swipe from
                startx = 200;
                starty = size.Height / 2;

                endx = (int)(size.Width * 0.8) - 50;
                endy = starty;
            }

            // perform the swipe
            //AppiumDriver.Instance.Swipe(startx, starty, endx, endy, 2000);
        }
Exemple #10
0
        //void Start () {}

        ///Physics
        //void FixedUpdate() {}
        //void OnTriggerEnter(Collider other){}
        //void OnCollisionEnter(Collision collision){}

        ///Game Logic
        void Update()
        {
            if (!autoDetect)
            {
                return;
            }
            bool isDown = false;
            bool isUp   = false;

            isDown = input.GetMouseButtonDown(0);
            isUp   = input.GetMouseButtonUp(0);
            if (isDown)
            {
                startPos = input.mousePosition;
            }
            if (isUp)
            {
                var endPos    = input.mousePosition;
                var direction = endPos - startPos;
                var distance  = direction.magnitude;
                var velocity  = distance / Time.deltaTime;
                if (velocity > minVelocity && distance > minDistance)
                {
                    direction.Normalize();
                    var angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
                    if (-angleRange / 2f < angle && angle < angleRange / 2f)
                    {
                        currentDirection = SwipeDirections.Right;
                        onSlide();
                    }
                    else if (90f - angleRange / 2f < angle && angle < 90 + angleRange / 2f)
                    {
                        currentDirection = SwipeDirections.Up;
                        onSlide();
                    }
                    else if (180f - angleRange / 2f < angle && angle < 180 + angleRange / 2f)
                    {
                        currentDirection = SwipeDirections.Left;
                        onSlide();
                    }
                    else if (-90f - angleRange / 2f < angle && angle < -90 + angleRange / 2f)
                    {
                        currentDirection = SwipeDirections.Down;
                        onSlide();
                    }
                }
                currentDirection = SwipeDirections.none;
            }
        }
        private void Update()
        {
            Direction = SwipeDirections.None;

            if (Input.GetMouseButtonDown(0))
            {
                TouchPosition = Input.mousePosition;
            }

            if (Input.GetMouseButtonUp(0))
            {
                Vector2 deltaswipe = TouchPosition - Input.mousePosition;
                if (Mathf.Abs(deltaswipe.x) > 0.1 && Mathf.Abs(deltaswipe.x) > Mathf.Abs(deltaswipe.y))
                {
                    Direction |= (deltaswipe.x > 0) ? SwipeDirections.Left : SwipeDirections.Right;
                }
                else if (Mathf.Abs(deltaswipe.y) > 0.1)
                {
                    Direction |= (deltaswipe.y > 0) ? SwipeDirections.Down : SwipeDirections.Up;
                }
                Debug.Log(Direction.ToString());
            }

            if (Direction != SwipeDirections.None)
            {
                string[] GhostList = { "Blinky", "Pinky", "Inky", "Clyde" };

                foreach (var Ghost in GhostList)
                {
                    if (GameObject.FindWithTag(Ghost))
                    {
                        GameObject.FindWithTag(Ghost).GetComponent <GhostAI>().ActivateGhost = true;
                    }
                    else
                    {
                        Debug.Log(Ghost + ": is not active.");
                    }
                }

                GameObject.FindWithTag("ReadyText").GetComponent <GUIText>().enabled = false;
            }
        }
    /// <summary>
    /// Checks the inputs. If it's a screen input (touches) or a controller input (buttons or keys)
    /// </summary>
    private void CheckInput()
    {
        bool isPressed = Input.GetMouseButton(0);

        if(isPressed)
        {
            _lastDetectedSwipe  = SwipeDirections.None;
            _swipeStartPosition = Input.mousePosition;
            _isActive           = true;
        }
    }
Exemple #13
0
    //Swipe preview is tested each frame.
    //If it exceeds the limits, it generates the preview events.
    void processSwipePreview()
    {
        direction = SwipeDirections.none;

        //process the usual swipes

        if (Mathf.Abs(swipeVector.x) > Mathf.Abs(swipeVector.y))
        {
            //decide: left/right swipe or up/down
            if (swipeVector.magnitude > usualSwipes.swipeDetectionLimit_LR)
            {
                // left or right
                if (swipeVector.x > 0f)
                {
                    direction = SwipeDirections.right;
                }
                else
                {
                    direction = SwipeDirections.left;
                }
            }
        }
        else
        {
            if (swipeVector.magnitude > usualSwipes.swipeDetectionLimit_UD)
            {
                // up or down
                if (swipeVector.y > 0f)
                {
                    direction = SwipeDirections.up;
                }
                else
                {
                    direction = SwipeDirections.down;
                }
            }
        }

        if (old_direction != direction)
        {
            switch (direction)
            {
            case SwipeDirections.left:
                usualSwipes.swipeLeftPreview.Invoke();
                break;

            case SwipeDirections.right:
                usualSwipes.swipeRightPreview.Invoke();
                break;

            case SwipeDirections.up:
                usualSwipes.swipeUpPreview.Invoke();
                break;

            case SwipeDirections.down:
                usualSwipes.swipeDownPreview.Invoke();
                break;

            default:
                //on (up, down) or none: reset the preview
                usualSwipes.swipePreviewReset.Invoke();
                break;
            }

            old_direction = direction;
        }
    }
Exemple #14
0
 void CatchSwipe(SwipeDirections direction)
 {
     actionCaptured = true;
     GameEvent.InvokeSwipe(direction);
 }
Exemple #15
0
 protected virtual void OnSwipe(SwipeDirections direction)
 {
 }
Exemple #16
0
        public async void DoAnimation(View view, SwipeDirections direction, int indexRow, DBHelper.ADVANCED_S_TABLES columnProperty)
        {
            switch (direction)
            {
            case SwipeDirections.LeftSwipe:
                // двигаем вьюху влево
                await Task.WhenAny
                (
                    view.TranslateTo(-100, 0, _millisecondsAnim),
                    view.FadeTo(0, _millisecondsAnim)
                );

                // затем переносим её вправо и двигаем на исходное место
                await view.TranslateTo(100, 0, 0);

                if (indexRow != -1)
                {
                    ChangeInfo(view, indexRow, columnProperty);
                }
                else
                {
                    //Label_number.Text = String.Format("Запись №{0}", current_position + 1);
                    picker_entries.SelectedIndex = _currentPosition;
                }
                await Task.WhenAny
                (
                    view.TranslateTo(0, 0, _millisecondsAnim),
                    view.FadeTo(1, _millisecondsAnim)
                );

                break;

            case SwipeDirections.RightSwipe:
                // двигаем вьюху вправо
                await Task.WhenAny
                (
                    view.TranslateTo(100, 0, 100),
                    view.FadeTo(0, 100)
                );

                // затем переносим её влево и двигаем на исходное место
                await view.TranslateTo(-100, 0, 0);

                if (indexRow != -1)
                {
                    ChangeInfo(view, indexRow, columnProperty);
                }
                else
                {
                    //Label_number.Text = String.Format("Запись №{0}", current_position + 1);
                    picker_entries.SelectedIndex = _currentPosition;
                }

                await Task.WhenAny
                (
                    view.TranslateTo(0, 0, 100),
                    view.FadeTo(1, 100)
                );

                break;
            }
        }
    /// <summary>
    /// Checks whether an upwards swipe had been performed.
    /// </summary>
    /// <returns>
    /// <c>true</c> if an upwards swipe had been made; otherwise <c>false</c>.
    /// </returns>
    /// <param name='yDistanceAbs'>
    /// Absolute value of the travelled distance in y.
    /// </param>
    /// <param name='yDistance'>
    /// Travelled distance in y.
    /// </param>
    /// <param name='swipeDistance'>
    /// Swipe's distance.
    /// </param>
    private bool CheckUpSwipe(float yDistanceAbs, float yDistance, float swipeDistance)
    {
        if(yDistanceAbs > swipeDistance && yDistance < 0 && _lastDetectedSwipe != SwipeDirections.Up)
        {
            _lastDetectedSwipe = SwipeDirections.Up;
            return true;
        }

        return false;
    }
    /// <summary>
    /// Checks whether a downwards swipe had been performed.
    /// </summary>
    /// <returns>
    /// <c>true</c> if a downwards swipe had been made; otherwise <c>false</c>.
    /// </returns>
    /// <param name='yDistanceAbs'>
    /// Absolute value of the travelled distance in y.
    /// </param>
    /// <param name='yDistance'>
    /// Travelled distance in y.
    /// </param>
    /// <param name='swipeDistance'>
    /// Swipe's distance.
    /// </param>
    private bool CheckDownSwipe(float yDistanceAbs, float yDistance, float swipeDistance)
    {
        if(yDistanceAbs > swipeDistance && yDistance > 0 && _lastDetectedSwipe != SwipeDirections.Down)
        {
            _lastDetectedSwipe = SwipeDirections.Down;
            return true;
        }

        return false;
    }
Exemple #19
0
 private void OnSwipe2(SwipeDirections Direction)
 {
     Debug.Log("2 " + Direction.ToString());
 }
    /// <summary>
    /// Checks whether a swipe to the right had been performed.
    /// </summary>
    /// <returns>
    /// <c>true</c> if a swipe to the right had been made; otherwise <c>false</c>.
    /// </returns>
    /// <param name='xDistanceAbs'>
    /// Absolute value of the travelled distance in x.
    /// </param>
    /// <param name='xDistance'>
    /// Travelled distance in x.
    /// </param>
    /// <param name='swipeDistance'>
    /// Swipe's distance.
    /// </param>
    private bool CheckRightSwipe(float xDistanceAbs, float xDistance, float swipeDistance)
    {
        if(xDistanceAbs > swipeDistance && xDistance < 0 && _lastDetectedSwipe != SwipeDirections.Right)
        {
            _lastDetectedSwipe = SwipeDirections.Right;
            return true;
        }

        return false;
    }
 public SwipeEventArgs(Vector2 pos, Vector2 v, SwipeDirections dir)
 {
     SwipePos       = pos;
     SwipeVector    = v;
     SwipeDirection = dir;
 }