Пример #1
0
    public void OnGestureSwipe(GestureDetector.Direction direction, float speedMultiplier = 1)
    {
        if (ignoreGesture == false && state == State.Show)
        {
            ignoreGesture = true;
            StartCoroutine(ResetIgnoreGestureFlag(speedMultiplier));

            if (direction == GestureDetector.Direction.ToLeft ||
                direction == GestureDetector.Direction.ToRight)
            {
                bool toLeft  = (direction == GestureDetector.Direction.ToLeft);
                bool flipped = currentShelf.Flip(toLeft, speedMultiplier);
                if (flipped)
                {
                    UpdateTitleAuthorAndEditButton();

                    float groundShift = toLeft? -GROUND_SHIFT : GROUND_SHIFT;
                    LeanTween.moveLocalX(ground.gameObject, groundShift, Shelf.FLIP_DURATION / speedMultiplier)
                    .setEase(LeanTweenType.easeInOutSine)
                    .setOnComplete(() => {
                        Vector3 backToOrigin = new Vector3(0, ground.localPosition.y, ground.localPosition.z);
                        ground.localPosition = backToOrigin;
                    });

                    audio.PlayOneShot(toLeft ? audioFlipLeft : audioFlipRight);
                }
            }
            else if (direction == GestureDetector.Direction.Pull ||
                     direction == GestureDetector.Direction.Push)
            {
                if ((currentShelf == sampleShelf && direction == GestureDetector.Direction.Push) ||
                    (currentShelf == userShelf && direction == GestureDetector.Direction.Pull))
                {
                    return;
                }

                if (currentShelf.CurrentPreset().Type == Preset.PresetType.Animated)
                {
                    currentShelf.CurrentPoser().StopMotion();
                }

                SwapShelf();
            }
        }
    }