예제 #1
0
    void Update()
    {
        if (flippingStarted)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > DelayBeforeStart)
            {
                if (nextPageCountDown < 0)
                {
                    if ((ControledBook.CurrentPaper <= ControledBook.EndFlippingPaper &&
                         Mode == FlipMode.RightToLeft) ||
                        (ControledBook.CurrentPaper > ControledBook.StartFlippingPaper &&
                         Mode == FlipMode.LeftToRight))
                    {
                        isPageFlipping = true;
                        PageFlipper.FlipPage(ControledBook, PageFlipTime, Mode, () => { isPageFlipping = false; });
                    }
                    else
                    {
                        flippingStarted = false;
                        this.enabled    = false;
                    }

                    nextPageCountDown = PageFlipTime + TimeBetweenPages + Time.deltaTime;
                }
                nextPageCountDown -= Time.deltaTime;
            }
        }
    }
예제 #2
0
    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
        public void Config(Size pageSize)
        {
            Contract.Requires(pageSize.IsValid());
            Debug.Assert(m_flipper == null);

            PageWidth              = pageSize.Width;
            PageHeight             = pageSize.Height;
            PageDoubleWidth        = pageSize.Width * 2;
            m_turningPageBack.Clip = new RectangleGeometry()
            {
                Rect = new Rect(new Point(), pageSize)
            };

            // TODO: HotSpot support need to be enabled with page content model
            m_flipper = new PageFlipper(pageSize, null, m_pageTop, m_curlShadow, m_shadow);

            m_flipper.IsAnimatingChanged += (sender, args) =>
            {
                if (!m_flipper.IsAnimating)
                {
                    m_working = false;
                    var stillWorking = startDance();
                    if (!stillWorking)
                    {
                        OnDoneFlipping();
                    }
                }
            };

            m_turningPageBack.RenderTransform = m_flipper.FlippingPageBackTransform;
            m_page2nd.Clip = m_flipper.NextPageClip;
            m_pageTop.Clip = m_flipper.PageHolderClip;

            m_contentBitmapLeft      = new WriteableBitmap((int)pageSize.Width, (int)pageSize.Height);
            m_contentBitmapRight     = new WriteableBitmap((int)pageSize.Width, (int)pageSize.Height);
            m_currentContentSnapshot = new WriteableBitmap((int)pageSize.Width * 2, (int)pageSize.Height);
            m_nextContentSnapshot    = new WriteableBitmap((int)pageSize.Width * 2, (int)pageSize.Height);

#if FUNKY
            var stack = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Opacity = .67
            };

            (new WriteableBitmap[] { m_currentContentSnapshot, m_nextContentSnapshot, m_contentBitmapLeft, m_contentBitmapRight }).ForEach(wp => {
                var image = new Image()
                {
                    Source = wp, Stretch = Stretch.UniformToFill, Height = 150, Width = 200
                };
                stack.Children.Add(image);
            });

            ((Grid)Content).Children.Add(stack);
#endif

            m_leftImage.Source  = m_contentBitmapLeft;
            m_rightImage.Source = m_contentBitmapRight;
        }
예제 #4
0
 private void PrePageHandle()
 {
     if (isPageFlipping || book.CurrentPaper <= 0)
     {
         return;
     }
     isPageFlipping = true;
     videoPlayer.Stop();
     PageFlipper.FlipPage(book, pageFlipTime, FlipMode.LeftToRight, () => {
         isPageFlipping = false;
         CheckPage(book.CurrentPaper);
     });
 }
예제 #5
0
 private void NextPageHandle()
 {
     if (isPageFlipping || book.CurrentPaper >= book.papers.Count)
     {
         return;
     }
     isPageFlipping = true;
     videoPlayer.Stop();
     PageFlipper.FlipPage(book, pageFlipTime, FlipMode.RightToLeft, () => {
         isPageFlipping = false;
         CheckPage(book.CurrentPaper);
     });
 }
예제 #6
0
 public void FlipLeftPage(Action callback = null)
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper <= 0)
     {
         return;
     }
     callback += () => { isPageFlipping = false; };
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.LeftToRight, callback);
 }
예제 #7
0
 public void FlipLeftPage()
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper <= 0)
     {
         return;
     }
     isPageFlipping = true;
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.LeftToRight, () => { isPageFlipping = false; });
 }
예제 #8
0
 public void FlipRightPage()
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper >= ControledBook.papers.Length)
     {
         return;
     }
     isPageFlipping = true;
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.RightToLeft, () => { isPageFlipping = false; });
 }
예제 #9
0
 public void FlipRightPage(Action callback = null)
 {
     if (isPageFlipping)
     {
         return;
     }
     if (ControledBook.CurrentPaper >= ControledBook.papers.Count)
     {
         return;
     }
     isPageFlipping = true;
     callback      += () => { isPageFlipping = false; };
     PageFlipper.FlipPage(ControledBook, PageFlipTime, FlipMode.RightToLeft, callback);
 }
예제 #10
0
    void Update()
    {
        if (flippingStarted)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > DelayBeforeStart)
            {
                if (nextPageCountDown < 0)
                {
                    if ((ControledBook.CurrentPaper <= ControledBook.EndFlippingPaper &&
                         Mode == FlipMode.RightToLeft) ||
                        (ControledBook.CurrentPaper > ControledBook.StartFlippingPaper &&
                         Mode == FlipMode.LeftToRight))
                    {
                        isPageFlipping = true;
                        PageFlipper.FlipPage(ControledBook, PageFlipTime, Mode, () => { isPageFlipping = false; });
                    }
                    else
                    {
                        flippingStarted = false;
                        this.enabled    = false;
                    }

                    nextPageCountDown = PageFlipTime + TimeBetweenPages + Time.deltaTime;
                }
                nextPageCountDown -= Time.deltaTime;
            }
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            UImanagerRef.audioS.clip = UImanagerRef.herbierPagePlus;
            UImanagerRef.audioS.Play();
            FlipRightPage();
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            UImanagerRef.audioS.clip = UImanagerRef.herbierPageMoins;
            UImanagerRef.audioS.Play();
            FlipLeftPage();
        }
    }