Пример #1
0
    public void ShowLatestLevel(int time)
    {
        for (int i = 0; i < time; i++)
        {
            Vector3 newLocation = panelLocation;
            currentPage++;

            if (horizontal)
            {
                newLocation += new Vector3(-Screen.width, 0, 0);
            }
            else
            {
                newLocation += new Vector3(0, Screen.height, 0);
            }

            StartCoroutine(SmoothMove(transform.position, newLocation, 0));
            panelLocation = newLocation;
        }

        if (OnSwiped != null)
        {
            OnSwiped.Invoke();
        }
    }
Пример #2
0
    public void OnEndDrag(PointerEventData data)
    {
        float percentage = horizontal ? (data.pressPosition.x - data.position.x) / Screen.width : (-data.pressPosition.y + data.position.y) / Screen.height;

        if (Mathf.Abs(percentage) >= percentThreshold)
        {
            Vector3 newLocation = panelLocation;
            if (percentage > 0 && currentPage < totalPages)
            {
                currentPage++;
                if (OnSwiped != null)
                {
                    OnSwiped.Invoke();
                }

                if (horizontal)
                {
                    newLocation += new Vector3(-Screen.width, 0, 0);
                }
                else
                {
                    newLocation += new Vector3(0, Screen.height, 0);
                }
            }
            else if (percentage < 0 && currentPage > 1)
            {
                currentPage--;
                if (OnSwiped != null)
                {
                    OnSwiped.Invoke();
                }

                if (horizontal)
                {
                    newLocation += new Vector3(Screen.width, 0, 0);
                }
                else
                {
                    newLocation += new Vector3(0, -Screen.height, 0);
                }
            }

            StartCoroutine(SmoothMove(transform.position, newLocation, easing));
            panelLocation = newLocation;
        }
        else
        {
            StartCoroutine(SmoothMove(transform.position, panelLocation, easing));
        }
    }
Пример #3
0
        private void SwipeGesture_Swiped(object sender, SwipedEventArgs e)
        {
            switch (e.Direction)
            {
            case SwipeDirection.Down:
                Content.TranslationY += 70;
                break;

            case SwipeDirection.Up:
                Content.TranslationY -= 70;
                break;

            case SwipeDirection.Left:
                Content.TranslationX -= 70;
                break;

            case SwipeDirection.Right:
                Content.TranslationX += 70;
                break;
            }

            OnSwiped?.Invoke(sender, e);
        }