Пример #1
0
    public void OnEndDrag(PointerEventData e)
    {
        if (_direction.y == 1)
        {
            float deltaY = e.position.y - e.pressPosition.y;
            if (_timer <= QUICKDRAG_TIME && Mathf.Abs(deltaY) > _height * QUICKDRAG_DIST)
            {
                if (deltaY > 0)
                {
                    _controller.UpTier();
                }
                else
                {
                    _controller.DownTier();
                }
            }
            else if (e.position.y < _height * LONGDRAG_MIN_Y && Mathf.Abs(deltaY) > _height * LONGDRAG_DIST)
            {
                _controller.UpTier();
            }
            else if (e.position.y > _height * (1f - LONGDRAG_MIN_Y) && Mathf.Abs(deltaY) > _height * LONGDRAG_DIST)
            {
                _controller.DownTier();
            }
            else
            {
                _controller.ResetTier();
            }
        }

        _dragging  = false;
        _direction = Vector2.zero;
        _timer     = 0;
    }