Exemple #1
0
 private void Hide(ref DialogParams dialogParams)
 {
     if (m_ShowingList.Count > 0)
     {
         Dialog dialog = m_ShowingList[m_ShowingList.Count - 1];
         if (!dialog.IsAlwaysShow)
         {
             dialog.Hide();
         }
     }
 }
Exemple #2
0
        private void Unique(ref DialogParams dialogParams)
        {
            if (m_ShowingList.Count > 0)
            {
                for (int i = 0; i < m_ShowingList.Count; i++)
                {
                    if (m_ShowingList[i].DialogClassName == dialogParams.DialogClassName && dialogParams.IsUnique)
                    {
                        // 移除此弹窗,序号i

                        m_ShowingList.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 把需要打开的弹窗的数据放入m_WaittingList中
        /// </summary>
        /// <param name="args">弹窗数据</param>
        /// <param name="index">插入的编号,默认插入最前面</param>
        /// <returns></returns>
        public int Push(ref DialogParams args, int index = 1)
        {
            // 判断数据是否有误
            if (args.DialogClassName == "" || args.DialogPrefabPath == "")
            {
                return(-1);
            }

            if (index >= 0 && index < m_WaittingList.Count)
            {
                m_WaittingList.Insert(index, args);
            }
            else
            {
                m_WaittingList.Add(args);
            }

            return(args.Id);
        }
Exemple #4
0
        private void Show(ref DialogParams dialogParams)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate(new GameObject());

            Type type = Type.GetType("Boking." + dialogParams.DialogClassName);

            Dialog dialog = gameObject.GetComponent(type) as Dialog;

            if (dialog == null)
            {
                dialog = gameObject.AddComponent(type) as Dialog;
            }

            m_ShowingList.Add(dialog);

            dialog.RequestData();

            dialog.Show();
        }
Exemple #5
0
        /// <summary>
        /// 打开m_WaittingList中第一个弹窗并打开
        /// </summary>
        /// <param name="stay">是否需要延迟打开</param>
        public void Pop(bool stay = false)
        {
            if (CanPop(stay))
            {
                DialogParams dialogParams = m_WaittingList[0];

                m_WaittingList.RemoveAt(0);

                if (dialogParams.ShowType == DialogShowType.NORMAL)
                {
                    Hide(ref dialogParams);

                    Unique(ref dialogParams);

                    Show(ref dialogParams);
                }
                else if (dialogParams.ShowType == DialogShowType.EVENT)
                {
                    // 派发事件通知可以打开此弹窗了
                }
            }
        }