コード例 #1
0
ファイル: AutoFlip.cs プロジェクト: dfengwji/unity
        void Update()
        {
            if (flippingStarted)
            {
                elapsedTime += Time.deltaTime;
                if (elapsedTime > DelayBeforeStart)
                {
                    if (nextPageCountDown < 0)
                    {
                        if ((ControledBook.CurrentPaper < targetPaper &&
                             Mode == FlipMode.RightToLeft) ||
                            (ControledBook.CurrentPaper > targetPaper &&
                             Mode == FlipMode.LeftToRight))
                        {
                            isPageFlipping = true;
                            PageFlipper.FlipPage(ControledBook, PageFlipTime, Mode, () => { isPageFlipping = false; });
                        }
                        else
                        {
                            flippingStarted            = false;
                            ControledBook.interactable = isBookInteractable;
                            this.enabled = false;
                        }

                        nextPageCountDown = PageFlipTime + TimeBetweenPages + Time.deltaTime;
                    }
                    nextPageCountDown -= Time.deltaTime;
                }
            }
        }
コード例 #2
0
ファイル: PageFlipper.cs プロジェクト: dfengwji/unity
        public static void FlipPage(BookPro book, float duration, FlipMode mode, Action OnComplete)
        {
            PageFlipper flipper = book.GetComponent <PageFlipper>();

            if (!flipper)
            {
                flipper = book.gameObject.AddComponent <PageFlipper>();
            }
            flipper.enabled     = true;
            flipper.book        = book;
            flipper.isFlipping  = true;
            flipper.duration    = duration - Time.deltaTime;
            flipper.finish      = OnComplete;
            flipper.xc          = (book.EndBottomLeft.x + book.EndBottomRight.x) / 2;
            flipper.pageWidth   = (book.EndBottomRight.x - book.EndBottomLeft.x) / 2;
            flipper.pageHeight  = Mathf.Abs(book.EndBottomRight.y);
            flipper.flipMode    = mode;
            flipper.elapsedTime = 0;
            float x;

            if (mode == FlipMode.RightToLeft)
            {
                x = flipper.xc + (flipper.pageWidth * 0.99f);
                float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc);
                book.DragRightPageToPoint(new Vector3(x, y, 0));
            }
            else
            {
                x = flipper.xc - (flipper.pageWidth * 0.99f);
                float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc);
                book.DragLeftPageToPoint(new Vector3(x, y, 0));
            }
        }
コード例 #3
0
ファイル: AutoFlip.cs プロジェクト: dfengwji/unity
 public void FlipLeftPage()
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper <= 0)
     {
         return;
     }
     isPageFlipping = true;
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.LeftToRight, () => { isPageFlipping = false; });
 }
コード例 #4
0
ファイル: AutoFlip.cs プロジェクト: dfengwji/unity
 public void FlipRightPage()
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper >= ControledBook.papers.Count)
     {
         return;
     }
     isPageFlipping = true;
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.RightToLeft, () => { isPageFlipping = false; });
 }