Example #1
0
        private void _Hide()
        {
            if (!hasShow)
            {
                return;
            }

            //Debug.Log("Panel has hide");


            for (int i = 0; i < 4; i++)
            {
                int index = showOrder[i];

                BlockButton button = buttons[index];
                if (button == null)
                {
                    continue;
                }
                if (button.IsHiding())
                {
                    continue;
                }

                button.Hide();
            }

            //hasShow = false;
        }
Example #2
0
        /// <summary>
        /// 创建一级菜单
        /// </summary>
        /// <param name="panelData">菜单所使用的数据</param>
        /// <param name="parentButton">打开菜单的按钮,如果为null表示根菜单</param>
        /// <returns></returns>
        private BlockPanel CreatePanel(BlockPanelData panelData, BlockButton parentButton)
        {
            //GameObject panelObj = PrefabUtils.CreateGameObjectToParent(MenuBase.gameObject, panelPrefab);
            GameObject panelObj = new GameObject("Panel");

            panelObj.transform.parent        = MenuBase.transform;
            panelObj.transform.localPosition = Vector3.zero;
            panelObj.transform.localScale    = Vector3.one;
            BlockPanel panel = panelObj.AddComponent <BlockPanel>();

            panel.menu = this;

            if (parentButton != null)
            {
                parentButton.AddNextPanel(panel);
            }

            for (int i = 0; i < panelData.buttons.Count; i++)
            {
                BlockButtonData buttonData = panelData.buttons[i];
                if (buttonData != null)
                {
                    BlockButton button = CreateButton(panel, (QUADRANT)i, buttonData);

                    if (buttonData.subPanel != null)
                    {
                        BlockPanel subPanel = CreatePanel(buttonData.subPanel, button);
                    }
                }
            }

            return(panel);
        }
Example #3
0
        /// <summary>
        /// 显示一个panel
        /// </summary>
        public void Show()
        {
            if (hasShow)
            {
                return;
            }

            showOrder = GetShowOrder();

            float delay = 0;

            for (int i = 0; i < 4; i++)
            {
                int         index  = showOrder[i];
                BlockButton button = buttons[index];
                if (button == null)
                {
                    continue;
                }

                int from = 0;
                if (i == 0)
                {
                    // 如果是第一个格子,则需要人为指定一个出现方向
                    from = 3 - index;
                }
                else if (i == 1 || i == 2)
                {
                    from = showOrder[0];
                }
                else
                {
                    from = showOrder[1];
                }


                // 设定按钮出现方向
                button.SetShowDirection((QUADRANT)from);

                button.InitToShow();

                button.Show(delay);

                delay += 0.12f;
            }

            hasShow            = true;
            hideTimerStartTime = Time.time;

            //Debug.Log("panel show:" + hideTimerStartTime);
        }
Example #4
0
        /*
         * /// <summary>
         * /// 根据给定象限,计算按钮中心点位置
         * /// </summary>
         * /// <param name="q"></param>
         * /// <returns></returns>
         * public Vector2 GetCenterByQuadrant(QUADRANT q)
         * {
         *  Vector2 vt = new Vector2();
         *  switch (q)
         *  {
         *      case QUADRANT.First:
         *          vt.x = (ButtonWidth + ButtonInterval) / 2;
         *          vt.y = (ButtonHeight + ButtonInterval) / 2;
         *          break;
         *      case QUADRANT.Second:
         *          vt.x = -(ButtonWidth + ButtonInterval) / 2;
         *          vt.y = (ButtonHeight + ButtonInterval) / 2;
         *          break;
         *      case QUADRANT.Thrid:
         *          vt.x = -(ButtonWidth + ButtonInterval) / 2;
         *          vt.y = -(ButtonHeight + ButtonInterval) / 2;
         *          break;
         *      case QUADRANT.Fourth:
         *          vt.x = (ButtonWidth + ButtonInterval) / 2;
         *          vt.y = -(ButtonHeight + ButtonInterval) / 2;
         *          break;
         *  }
         *
         *  return vt;
         * }
         */

        /// <summary>

        public void ResetButton()
        {
            for (int i = 0; i < 4; i++)
            {
                BlockButton button = buttons[i];
                if (button == null)
                {
                    continue;
                }

                TweenerGroupTransitObject tObj = button.GetComponent <TweenerGroupTransitObject>();
                tObj.resetTransit(true);
            }
        }
Example #5
0
        /// <summary>
        /// 关闭除指定位置之外的其他位置上的按钮所包含的自面板
        /// </summary>
        /// <param name="q"></param>
        public void HideOthersSubPanel(QUADRANT q)
        {
            for (int i = 0; i < buttons.Length; i++)
            {
                if (i == (int)q)
                {
                    continue;
                }

                BlockButton otherBtn = buttons[i];
                if (otherBtn == null)
                {
                    continue;
                }

                if (otherBtn.nextPanel != null)
                {
                    otherBtn.nextPanel.HideImmediately();
                }
            }
        }
Example #6
0
        /// <summary>
        /// 在指定象限添加一个按钮
        /// </summary>
        /// <param name="button"></param>
        /// <param name="q"></param>
        public BlockButton CreateButton(BlockPanel panel, QUADRANT q, BlockButtonData buttonData)
        {
            GameObject  buttonObj = PrefabUtils.CreateGameObjectToParent(panel.gameObject, BlockButtonPrefab);
            BlockButton button    = buttonObj.GetComponent <BlockButton>();

            // 初始化按钮
            button.Init(this, panel, q, buttonData);

            panel.SetButton(button, q);

            // 汇总按钮点击回调
            //button.cbClick += this.OnClickButton;

            buttonObj.SetActive(false);

            // 所有button在menu中留记录,以便修改
            // 这里暂时不判断按钮重名了……原则上,按钮不允许重名,可以在编辑器层面保证
            buttonDic.Add(button.buttonId, button);

            return(button);
        }
Example #7
0
        private void SetNeedHideWithChild(bool b, bool immediately)
        {
            keepShow = false;
            if (immediately)
            {
                hideTimerStartTime = -1000;
                //Debug.Log("need hide:" + hideTimerStartTime);
            }

            for (int i = 0; i < buttons.Length; i++)
            {
                BlockButton btn = buttons[i];
                if (btn == null)
                {
                    continue;
                }

                if (btn.nextPanel != null)
                {
                    btn.nextPanel.SetNeedHideWithChild(b, immediately);
                }
            }
        }
Example #8
0
 /// <summary>
 /// 设置一个指定位置的按钮
 /// </summary>
 /// <param name="button"></param>
 /// <param name="q"></param>
 public void SetButton(BlockButton button, QUADRANT q)
 {
     buttons[(int)q] = button;
 }