Exemplo n.º 1
0
        private void PanelFadeIn(AbstractPanel newPanel, float time)
        {
            Assert.IsTrue(newPanel != null);

            if (newPanel.IsVisable() == false)
            {
                newPanel.Enable();
            }

            CanvasGroup cg;

            cg = newPanel.m_TransFrom.GetComponent <CanvasGroup>();

            if (cg == null)
            {
                cg = newPanel.m_TransFrom.gameObject.AddComponent <CanvasGroup>();
            }
            cg.alpha = 0;
            MainLoop.Instance.UpdateForSeconds(() =>
            {
                if (!newPanel.IsVisable())
                {
                    return;
                }
                cg.alpha += Time.deltaTime / time;
            },
                                               time,
                                               () =>
            {
                if (!newPanel.IsVisable())
                {
                    return;
                }
                newPanel.m_TransFrom.position = GlobalVar.G_Canvas.transform.position;
            });
        }
        protected override void OnBegin(AbstractPanel panelBefore, AbstractPanel newPanel)
        {
            var speedX = Screen.width / this.time;
            var speedY = Screen.height / this.time;

            newPanel.Enable();

            switch (type)
            {
            case TransionType.PageDown:
                newPanel.m_TransFrom.position = GlobalVar.GCanvasButton;
                MainLoop.Instance.UpdateForSeconds(
                    () =>
                {
                    if (panelBefore != null)
                    {
                        panelBefore.m_TransFrom.Translate(Vector3.up * speedY * Time.deltaTime, Space.World);
                    }
                    newPanel.m_TransFrom.Translate(Vector3.up * speedY * Time.deltaTime, Space.World);
                },
                    this.time);
                break;

            case TransionType.PageRight:
                newPanel.m_TransFrom.position = GlobalVar.GCanvasRight;
                MainLoop.Instance.UpdateForSeconds(
                    () =>
                {
                    if (panelBefore != null)
                    {
                        panelBefore.m_TransFrom.Translate(Vector3.left * speedX * Time.deltaTime, Space.World);
                    }
                    newPanel.m_TransFrom.Translate(Vector3.left * speedX * Time.deltaTime, Space.World);
                },
                    this.time);
                break;

            case TransionType.PageUp:
                newPanel.m_TransFrom.position = GlobalVar.GCanvasTop;
                MainLoop.Instance.UpdateForSeconds(
                    () =>
                {
                    if (panelBefore != null)
                    {
                        panelBefore.m_TransFrom.Translate(Vector3.down * speedY * Time.deltaTime, Space.World);
                    }
                    newPanel.m_TransFrom.Translate(Vector3.down * speedY * Time.deltaTime, Space.World);
                },
                    this.time);
                break;

            case TransionType.PageLeft:
                newPanel.m_TransFrom.position = GlobalVar.GCanvasLeft;
                MainLoop.Instance.UpdateForSeconds(
                    () =>
                {
                    if (panelBefore != null)
                    {
                        panelBefore.m_TransFrom.Translate(Vector3.right * speedX * Time.deltaTime, Space.World);
                    }
                    newPanel.m_TransFrom.Translate(Vector3.right * speedX * Time.deltaTime, Space.World);
                },
                    this.time);
                break;
            }
        }