Пример #1
0
    void OnTurnComplete(GTweener tweener)
    {
        bool suc = (bool)tweener.userData;

        _draggingCorner = Corner.INVALID;
        if (suc && _turningTarget != -1)
        {
            _currentPage = _turningTarget;
        }
        if (suc && _coverTurningOp != CoverTurningOp.None)
        {
            if (_coverTurningOp == CoverTurningOp.ShowFront)
            {
                _coverStatus = CoverStatus.ShowingFront;
            }
            else if (_coverTurningOp == CoverTurningOp.ShowBack)
            {
                _coverStatus = CoverStatus.ShowingBack;
            }
            else
            {
                _coverStatus = CoverStatus.Hidden;
            }
        }
        _coverTurningOp = CoverTurningOp.None;
        _turningTarget  = -1;

        RenderPages();

        DispatchEvent("onTurnComplete");
    }
Пример #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pageIndex"></param>
    public void TurnTo(int pageIndex)
    {
        if (pageIndex < 0 || pageIndex > _pageCount - 1)
        {
            throw new Exception("Page index out of bounds: " + pageIndex);
        }

        GTween.Kill(this, true);

        if (_coverStatus == CoverStatus.ShowingFront)
        {
            _coverTurningOp = CoverTurningOp.HideFront;
            _draggingCorner = Corner.BR;
        }
        else if (_coverStatus == CoverStatus.ShowingBack)
        {
            _coverTurningOp = CoverTurningOp.HideBack;
            _draggingCorner = Corner.BL;
        }

        int tt1 = _currentPage;

        if (_currentPage % 2 == 0)
        {
            tt1--;
        }
        int tt2 = pageIndex;

        if (pageIndex % 2 == 0)
        {
            tt2--;
        }
        if (tt1 == tt2)
        {
            _currentPage   = pageIndex;
            _turningTarget = -1;
        }
        else
        {
            _turningTarget = pageIndex;
            if (_turningTarget < _currentPage)
            {
                _draggingCorner = Corner.BL;
            }
            else
            {
                _draggingCorner = Corner.BR;
            }
        }

        if (_draggingCorner == Corner.INVALID)
        {
            return;
        }

        StartTween();
    }
Пример #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="cover"></param>
    /// <param name="turnEffect"></param>
    public void ShowCover(CoverType cover, bool turnEffect)
    {
        GTween.Kill(this, true);

        if (_frontCover == null)
        {
            return;
        }

        if (turnEffect)
        {
            if (cover == CoverType.Front)
            {
                if (_coverStatus == CoverStatus.ShowingFront)
                {
                    return;
                }

                _coverTurningOp = CoverTurningOp.ShowFront;
                _draggingCorner = Corner.BL;
                _currentPage    = 0;
            }
            else
            {
                if (_coverStatus == CoverStatus.ShowingBack)
                {
                    return;
                }

                _coverTurningOp = CoverTurningOp.ShowBack;
                _draggingCorner = Corner.BR;
                _currentPage    = _pageCount - 1;
            }

            StartTween();
        }
        else
        {
            if (cover == CoverType.Front)
            {
                _currentPage = 0;
                _coverStatus = CoverStatus.ShowingFront;
            }
            else
            {
                _currentPage = _pageCount - 1;
                _coverStatus = CoverStatus.ShowingBack;
            }
            RenderPages();
        }
    }
Пример #4
0
    void __touchBegin(EventContext context)
    {
        GTween.Kill(this, true);

        _draggingCorner = (Corner)((GObject)context.sender).data;
        if (_draggingCorner == Corner.TL || _draggingCorner == Corner.BL)
        {
            if (_coverStatus == CoverStatus.ShowingBack)
            {
                _coverTurningOp = CoverTurningOp.HideBack;
            }
            else if (_objectNewIndice[0] == -1)
            {
                if (_frontCover != null && _coverStatus != CoverStatus.ShowingFront)
                {
                    _coverTurningOp = CoverTurningOp.ShowFront;
                }
                else
                {
                    _draggingCorner = Corner.INVALID;
                }
            }
            else
            {
                _turningTarget = _objectNewIndice[0] - 2;
                if (_turningTarget < 0)
                {
                    _turningTarget = 0;
                }
            }
        }
        else
        {
            if (_coverStatus == CoverStatus.ShowingFront)
            {
                _coverTurningOp = CoverTurningOp.HideFront;
            }
            else if (_objectNewIndice[1] == -1)
            {
                if (_backCover != null && _coverStatus != CoverStatus.ShowingBack)
                {
                    _coverTurningOp = CoverTurningOp.ShowBack;
                }
                else
                {
                    _draggingCorner = Corner.INVALID;
                }
            }
            else
            {
                _turningTarget = _objectNewIndice[1] + 1;
            }
        }

        if (_draggingCorner != Corner.INVALID)
        {
            _touchDownTime = Time.unscaledTime;
            UpdateDragPosition(context.inputEvent.position);
            RenderPages();
            PlayTurnEffect();

            context.CaptureTouch();
        }
    }