Exemplo n.º 1
0
        // Create dynamic map service webmap layer with popup
        private WebMapLayer CreateStateLayerWithPopup()
        {
            IList <FieldInfo> fieldinfos = new List <FieldInfo>();

            fieldinfos.Add(new FieldInfo()
            {
                FieldName = "STATE_NAME",
                Label     = "State",
                IsVisible = true
            });

            IList <MediaInfo> mediainfos = new List <MediaInfo>();
            MediaInfoValue    infovalue  = new MediaInfoValue();

            infovalue.Fields = new string[] { "POP2000,POP2007" };
            mediainfos.Add(new MediaInfo()
            {
                Type = MediaType.PieChart, Value = infovalue
            });

            PopupInfo popup = new PopupInfo()
            {
                FieldInfos = fieldinfos,
                MediaInfos = mediainfos,
                Title      = "Population Change between 2000 and 2007"
            };

            return(new WebMapLayer
            {
                Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
                LayerType = WebMapLayerType.ArcGISFeatureLayer,
                PopupInfo = popup
            });
        }
 public void UpdateInfo(PopupInfo info)
 {
     this.m_updateInfo = info;
     this.UpdateButtons(this.m_updateInfo.m_responseDisplay);
     if (base.m_showAnimState != DialogBase.ShowAnimState.IN_PROGRESS)
     {
         this.UpdateInfoAfterAnim();
     }
 }
Exemplo n.º 3
0
        static public void Add(string Caption, string Text, PopupType Type, EventType Event)
        {
            PopupInfo popup = new PopupInfo();

            popup.Caption = Caption;
            popup.Text    = Text;
            popup.Type    = Type;
            popup.Event   = Event;
            Add(popup);
        }
Exemplo n.º 4
0
    void StackPopup(PopupInfo menu)     //入栈
    {
        PopupInfo current = GetCurrentPopup();

        if (current != null)
        {
            current.SetActive(false);
        }
        mPopupStack.Insert(0, menu);
    }
Exemplo n.º 5
0
    public Dictionary <ePopupMode, PopupBase> mPopupCache = new Dictionary <ePopupMode, PopupBase>(); //弹出框的字典
    public PopupInfo GetCurrentPopup()                                                                //从栈中取出当前的弹出框
    {
        PopupInfo result = null;

        if (mPopupStack.Count > 0)
        {
            result = mPopupStack[0];
        }
        return(result);
    }
Exemplo n.º 6
0
    public void OnFinishedShow()
    {
        bShow = true;
        PopupInfo info = GetCurrentPopup();

        if (info != null && info.Obj != null)
        {
            info.Obj.OnFinishedShow();
        }
    }
Exemplo n.º 7
0
    PopupInfo PopPopup()     //移除栈顶的窗口
    {
        PopupInfo result = null;

        if (mPopupStack.Count > 0)
        {
            result = mPopupStack[0];
            mPopupStack.RemoveAt(0);
        }
        return(result);
    }
 private void InitInfo()
 {
     if (this.m_popupInfo == null)
     {
         this.m_popupInfo = new PopupInfo();
     }
     if (this.m_popupInfo.m_headerText == null)
     {
         this.m_popupInfo.m_headerText = GameStrings.Get("GLOBAL_DEFAULT_ALERT_HEADER");
     }
 }
Exemplo n.º 9
0
        public static PopupInfo FindPopupInfoFrromId(string id)
        {
            PopupInfo data = null;

            data = popupInfolList.Find(x => x.Id == id);
            if (data == null)
            {
                Debugger.Log("Error : Not Found In PopupInfo . ID :" + id);
            }
            return(data);
        }
Exemplo n.º 10
0
        //从popLayerPopUps和uiLayerPopUps里面取出一个优先级最高的弹窗,并展示出来
        private void CheckToShowPopups()
        {
            //先遍历popLayerPopUps的,因为之前插入已经是依据优先级牌序插入的,所以从尾部遍历就ok了
            if (popLayerPopUps.Count > 0)
            {
                if (currentShowPopupInfo != null)
                {
                    if (currentShowPopupInfo == popLayerPopUps[popLayerPopUps.Count - 1])
                    {
                        //尽管当前弹窗就是优先级最高的弹窗,但可能该弹窗被动态插入了子窗口,所以还是要setvisible true一下,用来把子窗口显示出来
                        currentShowPopupInfo.SetPopupInfoVisible(true);

                        return;
                    }
                }

                //当前窗口不是优先级最高的弹窗,则把当前窗口隐藏,并显示优先级最高的弹窗
                if (currentShowPopupInfo != null)
                {
                    currentShowPopupInfo.SetPopupInfoVisible(false);
                }

                currentShowPopupInfo = popLayerPopUps[popLayerPopUps.Count - 1];
                currentShowPopupInfo.SetPopupInfoVisible(true);

                return;
            }

            //遍历uiLayerPopUps的:逻辑同上面的popLayerPopUps遍历方法
            if (uiLayerPopUps.Count > 0)
            {
                if (currentShowPopupInfo != null)
                {
                    if (currentShowPopupInfo == uiLayerPopUps[uiLayerPopUps.Count - 1])
                    {
                        currentShowPopupInfo.SetPopupInfoVisible(true);
                        return;
                    }
                }

                if (currentShowPopupInfo != null)
                {
                    currentShowPopupInfo.SetPopupInfoVisible(false);
                }
                currentShowPopupInfo = uiLayerPopUps[uiLayerPopUps.Count - 1];
                currentShowPopupInfo.SetPopupInfoVisible(true);

                return;
            }

            //popLayerPopUps和uiLayerPopUps里面都没有东西,则什么都不展示,并置currentShowPopupInfo为null
            currentShowPopupInfo = null;
        }
Exemplo n.º 11
0
    /// <summary> Populates the next popup and starts it animating in </summary>
    void ShowNextPopup()
    {
        currentPopupInfo = queuedPopups.Dequeue();
        currentPopup     = popups[currentPopupInfo._popupType];
        currentPopup.StartShowing(currentPopupInfo);
        gameObject.SetActive(true);

        // Set state
        animSpeed    = currentPopup.ShowAnimSpeed;
        animProgress = 0f;
        state        = States.PoppingUp;
    }
 private void UpdateTexts(PopupInfo popupInfo)
 {
     this.m_alertText.RichText  = this.m_popupInfo.m_richTextEnabled;
     this.m_alertText.Alignment = this.m_popupInfo.m_alertTextAlignment;
     if (popupInfo.m_headerText == null)
     {
         popupInfo.m_headerText = GameStrings.Get("GLOBAL_DEFAULT_ALERT_HEADER");
     }
     this.m_alertText.Text = popupInfo.m_text;
     this.m_okayButton.SetText((popupInfo.m_okText != null) ? popupInfo.m_okText : GameStrings.Get("GLOBAL_OKAY"));
     this.m_confirmButton.SetText((popupInfo.m_confirmText != null) ? popupInfo.m_confirmText : GameStrings.Get("GLOBAL_CONFIRM"));
     this.m_cancelButton.SetText((popupInfo.m_cancelText != null) ? popupInfo.m_cancelText : GameStrings.Get("GLOBAL_CANCEL"));
 }
Exemplo n.º 13
0
    private void Awake()
    {
        if (!Instance)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        DontDestroyOnLoad(this);
    }
 void attributeChangeEventHookups(PopupInfo popupInfo, bool hookup)
 {
     if (PopupInfo != null)
     {
         if (hookup)
         {
             PopupInfo.PopupItem.PropertyChanged += PopupItem_PropertyChanged;
         }
         else
         {
             PopupInfo.PopupItem.PropertyChanged -= PopupItem_PropertyChanged;
         }
     }
 }
        public CreateWebMapObject()
        {
            InitializeComponent();

            //Define BaseMap Layer
            basemap = new BaseMap()
               {
               Layers = new List<WebMapLayer> { new WebMapLayer { Url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" } }
               };

            //Add a ArcGISDynamicMapService
            operationLayers.Add(new WebMapLayer
            {
                Url = "http://serverapps10.esri.com/ArcGIS/rest/services/California/MapServer",
                VisibleLayers = new List<object> { 0, 1, 3, 6, 9 }
            });

            //Define popup
            IList<FieldInfo> fieldinfos = new List<FieldInfo>();
            fieldinfos.Add(new FieldInfo() { FieldName = "STATE_NAME", Label = "State", Visible = true });

            IList<MediaInfo> mediainfos = new List<MediaInfo>();
            MediaInfoValue infovalue = new MediaInfoValue();
            infovalue.Fields = new string[] { "POP2000,POP2007" };
            mediainfos.Add(new MediaInfo() { Type = MediaType.PieChart, Value = infovalue });

            PopupInfo popup = new PopupInfo() { FieldInfos = fieldinfos, MediaInfos = mediainfos, Title = "Population Change between 2000 and 2007", };

            //Add a Feature Layer with popup
            operationLayers.Add(new WebMapLayer
            {
                Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
                Mode = FeatureLayer.QueryMode.OnDemand,
                PopupInfo = popup
            });

            //Perform Query to get a featureSet and add to webmap as featurecollection
            QueryTask qt = new QueryTask() { Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0" };
            qt.ExecuteCompleted += qt_ExecuteCompleted;

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
            query.OutFields.Add("*");
            query.Where = "magnitude > 3.5";
            query.ReturnGeometry = true;
            qt.Failed += (a, b) =>
              {
                  MessageBox.Show("QueryTask failed to execute:" + b.Error);
              };
            qt.ExecuteAsync(query);
        }
Exemplo n.º 16
0
 private void Activate()
 {
     //--Component apply
     foreach (var skillComponent in skillComponents)
     {
         string error = skillComponent.Apply(casterStatus);
         if (!string.IsNullOrEmpty(error))
         {
             CallSkill(false);
             PopupInfo.setText(error, casterStatus.transform, 1, Color.cyan);
             return;
         }
     }
 }
Exemplo n.º 17
0
    /// <summary> Populates & shows the specified popup </summary>
    /// <param name="_popupInfo"> Info of popup to show and its contents </param>
    public void ShowOrEnqueue(PopupInfo _popupInfo)
    {
        if (popups.Keys.Count == 0)
        {
            InitChildPopups();
        }

        queuedPopups.Enqueue(_popupInfo);

        if (state == States.Idle)
        {
            ShowNextPopup();
        }
    }
Exemplo n.º 18
0
        protected override void Enable()
        {
            this.Enable();
            string    formattedText = TextCollectionUtility.InitializationFailureKeys.GetFormattedText(m_cause);
            PopupInfo popupInfo     = default(PopupInfo);

            popupInfo.title   = 77080;
            popupInfo.message = formattedText;
            popupInfo.buttons = new ButtonData[1]
            {
                new ButtonData(27169, Main.Quit)
            };
            popupInfo.selectedButton = 1;
            PopupInfoManager.ShowApplicationError(popupInfo);
        }
    public void StartPopup(PopupInfo info)
    {
        FindObjectOfType <PlayerControls>().frozen = true;

        Cursor.lockState = CursorLockMode.None;

        nameText.text = info.name;
        sentences.Clear();
        box.SetActive(true);

        foreach (string sentence in info.sentences)
        {
            sentences.Enqueue(sentence);
        }
        DisplayNextSentence();
    }
Exemplo n.º 20
0
        private void OnCloneRequest(int titleid, int desc)
        {
            PopupInfo  info;
            StateLayer val2 = default(StateLayer);

            if (DeckUtility.GetRemainingSlotsForWeapon(new DeckInfo(m_selectedSlot.DeckInfo).Weapon) > 0)
            {
                StateLayer val = default(StateLayer);
                if (StateManager.TryGetLayer("PlayerUI", ref val))
                {
                    ButtonData[] buttons = new ButtonData[2]
                    {
                        new ButtonData(48064, OnCloneConfirme),
                        new ButtonData(26918, OnCloneCanceld)
                    };
                    PopupInfoManager.ClearAllMessages();
                    StateContext chainEnd = val.GetChainEnd();
                    info = new PopupInfo
                    {
                        title          = titleid,
                        message        = desc,
                        buttons        = buttons,
                        selectedButton = 1,
                        style          = PopupStyle.Normal
                    };
                    PopupInfoManager.Show(chainEnd, info);
                }
            }
            else if (StateManager.TryGetLayer("PlayerUI", ref val2))
            {
                ButtonData[] buttons2 = new ButtonData[1]
                {
                    new ButtonData(27169, OnCloneCanceld)
                };
                PopupInfoManager.ClearAllMessages();
                StateContext chainEnd2 = val2.GetChainEnd();
                info = new PopupInfo
                {
                    title          = 4176,
                    message        = 52887,
                    buttons        = buttons2,
                    selectedButton = 1,
                    style          = PopupStyle.Normal
                };
                PopupInfoManager.Show(chainEnd2, info);
            }
        }
        static void OnPopupInfoChange(DependencyObject o, DependencyPropertyChangedEventArgs args)
        {
            HoverResults hr           = o as HoverResults;
            PopupInfo    oldPopupInfo = args.OldValue as PopupInfo;

            if (oldPopupInfo != null)
            {
                hr.attributeChangeEventHookups(oldPopupInfo, false);
            }
            if (hr.PopupInfo != null)
            {
                hr.attributeChangeEventHookups(hr.PopupInfo, true);
            }
            if (hr.PopUpContainer != null)
            {
                hr.PopUpContainer.DataContext = hr.PopupInfo;
            }
        }
    private void UpdateAll(PopupInfo popupInfo)
    {
        this.m_alertIcon.SetActive(popupInfo.m_showAlertIcon);
        bool flag  = popupInfo.m_iconSet == PopupInfo.IconSet.Default;
        bool flag2 = popupInfo.m_iconSet == PopupInfo.IconSet.Alternate;

        for (int i = 0; i < this.m_buttonIconsSet1.Count; i++)
        {
            this.m_buttonIconsSet1[i].SetActive(flag);
        }
        for (int j = 0; j < this.m_buttonIconsSet2.Count; j++)
        {
            this.m_buttonIconsSet2[j].SetActive(flag2);
        }
        this.UpdateHeaderText(popupInfo.m_headerText);
        this.UpdateTexts(popupInfo);
        this.UpdateLayout();
    }
        // Create dynamic map service webmap layer with popup
        private WebMapLayer CreateStateLayerWithPopup()
        {
            IList<FieldInfo> fieldinfos = new List<FieldInfo>();
            fieldinfos.Add(new FieldInfo() { FieldName = "STATE_NAME", Label = "State", IsVisible = true });

            IList<MediaInfo> mediainfos = new List<MediaInfo>();
            MediaInfoValue infovalue = new MediaInfoValue();
            infovalue.Fields = new string[] { "POP2000,POP2007" };
            mediainfos.Add(new MediaInfo() { Type = MediaType.PieChart, Value = infovalue });

            PopupInfo popup = new PopupInfo() { FieldInfos = fieldinfos, MediaInfos = mediainfos, Title = "Population Change between 2000 and 2007", };

            return new WebMapLayer
            {
                Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
                PopupInfo = popup
            };
        }
Exemplo n.º 24
0
        public static int UpdatePopupInfo(PopupInfo pi)
        {
            SqlParameter ret = new SqlParameter("@ret", SqlDbType.Int);

            ret.Direction = ParameterDirection.Output;

            // add user to SolidCP Users table
            SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
                                      ObjectQualifier + "UpdatePopupInfo",
                                      ret,
                                      //prmErrormsg,
                                      new SqlParameter("@Id", pi.Id),
                                      new SqlParameter("@alerttext", pi.AlertText),
                                      new SqlParameter("@popuptext", pi.PopupText));

            //string errormsg = Convert.ToString(prmErrormsg.Value);
            return(Convert.ToInt32(ret.Value));
        }
Exemplo n.º 25
0
    public void ReceivDamage(float amount, Color popupColor)
    {
        if (IsDead)
        {
            return;
        }

        if (amount < 1.0f)
        {
            PopupInfo.setText("Miss", transform, popupDmgMotion, popupColorMiss);
            return;
        }
        SetHealth(Health - amount);
        if (Health == 0.0f)
        {
            Death();
        }
        PopupInfo.setText(amount.ToString("N0"), transform, popupDmgMotion, popupColor);
    }
Exemplo n.º 26
0
        public void ShowPopup(PopupInfo info)
        {
            UN.SetText(_header, info.PopUpLabel);
            UN.SetText(_body, info.PopUpText);

            bool okBtn     = false;
            bool cancelBtn = false;

            switch (info.Mode)
            {
            case PopupType.Notification:
                okBtn = true;
                break;

            case PopupType.Question:
                okBtn     = true;
                cancelBtn = true;
                break;
            }

            UN.SetActive(_ok, okBtn);
            UN.SetActive(_cancel, cancelBtn);
            UN.SetActive(_root, true);

            if (info.StringArgs.Length > 0)
            {
                UN.SetText(_okBtnText, info.StringArgs[0]);
            }
            else
            {
                UN.SetText(_okBtnText, _defaultOkText);
            }

            if (info.StringArgs.Length > 1)
            {
                UN.SetText(_okBtnText, info.StringArgs[1]);
            }
            else
            {
                UN.SetText(_okBtnText, _defaultCancelText);
            }
        }
Exemplo n.º 27
0
    void InitCurrentPopup(bool is_new)                      //初始化当前的弹出框
    {
        PopupInfo info  = GetCurrentPopup();                //得到当前的弹出框
        IPopup    popup = info.Obj.GetComponent <IPopup>(); //得到接口

        try
        {
            if (popup == null)
            {
                throw new System.Exception(string.Format("not found {0}", info.mode));
            }
            info.bExternalClose = popup.bCloseExternalClick;
            popup.parent        = this;
            popup.SetParams(is_new, info.parms);
        }
        catch (System.Exception e)
        {
            Debug.LogException(e);
        }
    }
Exemplo n.º 28
0
        private void OnDestroy(GameObject gameObj)
        {
            do
            {
                //找到该弹窗,并把该弹窗的信息从相应的队列里面移除,并置标记位,让下一帧去重新检查显示新窗口
                bool hasFind = false;
                //先从uiLayerPopUps里面找
                for (int idx = 0; idx < uiLayerPopUps.Count; ++idx)
                {
                    if (uiLayerPopUps[idx].gameObj == gameObj)
                    {
                        uiLayerPopUps.RemoveAt(idx);
                        hasFind = true;
                        break;
                    }
                }

                //如果已经在uiLayerPopUps里面找到,则跳出循环
                if (hasFind)
                {
                    break;
                }

                //从popLayerPopUps里面找
                for (int idx = 0; idx < popLayerPopUps.Count; ++idx)
                {
                    if (popLayerPopUps[idx].gameObj == gameObj)
                    {
                        popLayerPopUps.RemoveAt(idx);
                        hasFind = true;
                        break;
                    }
                }

                //如果已经在popLayerPopUps里面找到,则跳出循环
                if (hasFind)
                {
                    break;
                }

                //不在popLayerPopUps里面也不在uiLayerPopUps,说明可能是一个子窗口
                //从uiLayerPopUps所有的窗口里面的子窗口里面去找
                for (int idx = 0; idx < uiLayerPopUps.Count && !hasFind; ++idx)
                {
                    for (int idx2 = 0; idx2 < uiLayerPopUps[idx].childObjs.Count; ++idx2)
                    {
                        if (uiLayerPopUps[idx].childObjs[idx2].gameObj == gameObj)
                        {
                            uiLayerPopUps[idx].childObjs.RemoveAt(idx2);
                            hasFind = true;
                            break;
                        }
                    }
                }

                //
                if (hasFind)
                {
                    break;
                }

                //不在popLayerPopUps里面也不在uiLayerPopUps,说明可能是一个子窗口
                //从popLayerPopUps所有的窗口里面的子窗口里面去找
                for (int idx = 0; idx < popLayerPopUps.Count && !hasFind; ++idx)
                {
                    for (int idx2 = 0; idx2 < popLayerPopUps[idx].childObjs.Count; ++idx2)
                    {
                        if (popLayerPopUps[idx].childObjs[idx2].gameObj == gameObj)
                        {
                            popLayerPopUps[idx].childObjs.RemoveAt(idx2);
                            hasFind = true;
                            break;
                        }
                    }
                }

                if (hasFind)
                {
                    break;
                }

                Lucky.LuckyUtils.Log("Popup On Dialog destroy, Can not find Dialog!");
            } while (false);

            if (currentShowPopupInfo != null)
            {
                if (currentShowPopupInfo.gameObj == gameObj)
                {
                    currentShowPopupInfo = null;
                }
            }

            needCheckToShowPopup = true;
        }
 public PopupItem(IdentifyFeature identifyFeature, PopupInfo popupInfo)
 {
     IdentifyFeature = identifyFeature;
     PopupInfo = popupInfo;
 }
Exemplo n.º 30
0
 public void UpdateAll(PopupInfo popupInfo)
 {
     object[] objArray1 = new object[] { popupInfo };
     base.method_8("UpdateAll", objArray1);
 }
Exemplo n.º 31
0
 public void SetInfo(PopupInfo info)
 {
     object[] objArray1 = new object[] { info };
     base.method_8("SetInfo", objArray1);
 }
Exemplo n.º 32
0
        // for lua
        public void AddUiLayerPopup2(GameObject popUp)
        {
            //判定预设是否存在,否则返回null
            Canvas canvas = null;

            // added by jackmo at 2017-2-6,扫描bug,popUp判空
            if (popUp == null)
            {
                Lucky.LuckyUtils.Log("PopupManager, AddPopupNew, Cannot Instantiate the prefab!");
                return;
            }
            // added end

            //GetCanvasByLayer:获取对应的canvas:UICanvas or PopCanvas:如果有则直接取值,如果没有则会执行创建过程
            canvas = GetCanvasByLayer(PopCanvasLayer.E_UILayer);

            //设置popUp位置:居中显示在屏幕上
            popUp.transform.SetParent(canvas.transform, false);
            popUp.transform.localPosition = Vector3.zero;
            popUp.transform.localScale    = Vector3.one;
            (popUp.transform as RectTransform).SetAsLastSibling();

            //给所有的物件都挂上DestroyEventUI:该脚本的OnDestory函数里面会通知到PopUpMgr.OnDestroy
            //所以实现了PopUpMgr监听弹窗的销毁事件
            DestroyEventUI destroyUi = popUp.GetComponent <DestroyEventUI>();

            if (destroyUi == null)
            {
                destroyUi = popUp.AddComponent <DestroyEventUI>();
            }
            destroyUi.onDestroy += OnDestroy;

            //创建popInfo,准备插入到显示队列里面去
            PopupInfo popInfo = new PopupInfo();

            popInfo.gameObj      = popUp;
            popInfo.showPriority = 0;

            popInfo.strId = "";

            //插入过程:根据showPriority从队列尾部遍历插入
            bool insertSuc = false;

            for (int idx = uiLayerPopUps.Count - 1; idx >= 0; --idx)
            {
                if (uiLayerPopUps[idx].showPriority <= 0)
                {
                    uiLayerPopUps.Insert(idx + 1, popInfo);
                    insertSuc = true;
                    break;
                }
            }
            //没找到合适的位置插入,说明该弹窗的showPriority是最小的,所以往顶部插
            if (!insertSuc)
            {
                uiLayerPopUps.Insert(0, popInfo);
            }

            //刚插入进去,等下一帧update里面会执行checkshow逻辑,如果该弹窗优先级是最高的,则她会在下一帧弹出来
            popUp.GetComponent <BaseScene>().SetVisable(false);
            needCheckToShowPopup = true;
        }
Exemplo n.º 33
0
        //往一个弹窗上面挂载子弹窗
        //prefabName:预设名称,parent:所需要挂载的母弹窗的gameObj,showPriority:显示优先级,id:id
        private GameObject AddPopUpInParent(string prefabName, GameObject parent, int showPriority, string id = "")
        {
            //判定预设是否存在,否则返回null
            GameObject prefab = (GameObject)Resources.Load(prefabName);

            if (prefab == null)
            {
                Lucky.LuckyUtils.Log("AddPopup, Cannot find prefab!");
                return(null);
            }

            Canvas     canvas = null;
            GameObject popUp  = null;

            //创建PopupInfo对象,准备插入到母弹窗的childObjs里面
            PopupInfo popInfo = new PopupInfo();

            popInfo.showPriority = showPriority;
            popInfo.strId        = id;

            //母弹窗的相关信息:需要从uiLayerPopUps和popLayerPopUps两个队列里面去找
            PopupInfo parentPopUpInfo = null;

            //从uiLayerPopUps队列里面去找母弹窗信息
            for (int idx = 0; idx < uiLayerPopUps.Count; ++idx)
            {
                if (uiLayerPopUps[idx].gameObj == parent)
                {
                    parentPopUpInfo = uiLayerPopUps[idx];
                }
            }

            //如果uiLayerPopUps里面没找到,则再去popLayerPopUps队列里面去找母弹窗信息
            if (parentPopUpInfo == null)
            {
                for (int idx = 0; idx < popLayerPopUps.Count; ++idx)
                {
                    if (popLayerPopUps[idx].gameObj == parent)
                    {
                        parentPopUpInfo = popLayerPopUps[idx];
                    }
                }
            }

            //uiLayerPopUps和popLayerPopUps队列里面都没有找到,则输出错误日志并返回
            if (parentPopUpInfo == null)
            {
                Lucky.LuckyUtils.Log("Show Pop in paretn, can not find parent in popups!");
                return(null);
            }

            //获取母弹窗父节点的canvas信息,用来设定子弹窗的一些位置信息
            canvas = parentPopUpInfo.gameObj.transform.parent.gameObject.GetComponent <Canvas>();
            if (canvas == null)
            {
                //母弹窗不是挂在canvas上的?输出错误日志并返回
                Lucky.LuckyUtils.Log("AddPopupInParent, parent father is not Canvas!");
                return(null);
            }

            //母弹窗存在,且母弹窗的父节点canvas也存在,则创建子窗口组件
            popUp = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

            //j将子窗口插入到母窗口的childObjs队列里面
            popInfo.gameObj = popUp;
            parentPopUpInfo.childObjs.Add(popInfo);

            //设置子窗口组件的位置信息
            popUp.transform.SetParent(canvas.transform, false);
            popUp.transform.localPosition = Vector3.zero;
            popUp.transform.localScale    = Vector3.one;
            (popUp.transform as RectTransform).SetAsLastSibling();

            //给所有的物件都挂上DestroyEventUI:该脚本的OnDestory函数里面会通知到PopUpMgr.OnDestroy
            //所以实现了PopUpMgr监听弹窗的销毁事件
            DestroyEventUI destroyUi = popUp.GetComponent <DestroyEventUI>();

            if (destroyUi == null)
            {
                destroyUi = popUp.AddComponent <DestroyEventUI>();
            }
            destroyUi.onDestroy += OnDestroy;

            //刚插入进去,等下一帧update里面会执行checkshow逻辑,如果该弹窗优先级是最高的,则她会在下一帧弹出来
            popUp.GetComponent <BaseScene>().SetVisable(false);
            needCheckToShowPopup = true;
            return(popUp);
        }
Exemplo n.º 34
0
    // Activate the popup, and set its contents based on Dictionary lookup
    // Different popup for left and right hand screen
    public static void SetPopupContent(string leftKey, string rightKey)
    {
        try{
            rightPopup = tutorialParts[rightKey];
        } catch (KeyNotFoundException) {
            Debug.LogError ("Missing Tutorial key: " + rightKey);
        }

        try{
            leftPopup = tutorialParts[leftKey];
        } catch (KeyNotFoundException) {
            Debug.LogError ("Missing Tutorial key: " + leftKey);
        }
        // Don't show the popup if we have shown both before
        if(leftPopup.shown && rightPopup.shown) return;

        // If not, mark them as shown
        leftPopup.shown = true;
        rightPopup.shown = true;

        tutorialParts[leftKey] = leftPopup;
        tutorialParts[rightKey] = rightPopup;

        dialogueThisFrame = true;
    }