Ejemplo n.º 1
0
 /// <summary>
 /// 实例化对应的ui
 /// </summary>
 /// <param name="panelType"></param>
 private BasePanel SpawnPanel(PanelName panelType)
 {
     if (panelPath.TryGetValue(panelType, out string path))
     {
         GameObject g = GameObject.Instantiate(Resources.Load(path)) as GameObject;
         if (panelType == PanelName.Message)
         {
             g.transform.SetParent(noticePanelTf, false);
         }
         else
         {
             g.transform.SetParent(normalPanelTf, false);
         }
         //g.transform.SetParent(canvasTransform, false);
         BasePanel panel = g.GetComponent <BasePanel>();
         //panel.SetUIMgr = this;
         panelDict.Add(panelType, panel);
         return(panel);
     }
     else
     {
         Debug.Log("空");
         return(null);
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 切换UI Panel
    /// </summary>
    /// <param name="panelName"></param>
    public static void SwitchPanel(PanelName panelName)
    {
        EventParamete eventParamete = new EventParamete();

        eventParamete.AddParameter(panelName);
        EventManager.TriggerEvent(GenericEventEnumType.Message, MTFrame.EventType.PanelSwitch.ToString(), eventParamete);
    }
Ejemplo n.º 3
0
    public override void OnListenerMessage(EventParamete parameteData)
    {
        //接收监听事件的数据,然后用swich判断做处理

        //除此之外,也可以在这里监听UDP传输的数据,但是接收的数据是子线程数据,要通过队列接收,
        //然后在update转换成主线程数据,才能对数据进行处理

        //if(parameteData.EvendName == "aaa")
        //{
        //    //获取数据parameteData.GetParameter<string>()[0]
        //    GetVs.Enqueue(parameteData.GetParameter<string>()[0]);
        //}

        if (parameteData.EvendName == MTFrame.EventType.PanelSwitch.ToString())
        {
            PanelName panelName = parameteData.GetParameter <PanelName>()[0];
            switch (panelName)
            {
            case PanelName.WaitPanel:

                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 打开指定弹框
    /// </summary>
    /// <param name="sceneType"></param>
    /// <param name="sceneArgs">场景参数</param>
    public void ShowPanel(PanelName panelName, params object[] sceneArgs)
    {
        if (panels.ContainsKey(panelName))
        {
            //Debug.LogError("该面板已打开!");
            current = panels[panelName];
            current.gameObject.SetActive(false);
            current.OnInit(sceneArgs);
            current.OnShowing();
            ViewMgr.Instance.SetLayer(current.gameObject, LayerType.Panel);
        }
        else
        {
            GameObject go    = new GameObject(panelName.ToString());
            Type       mType = Type.GetType(panelName.ToString());
            PanelBase  pb    = go.AddComponent(mType) as PanelBase; //sceneType.tostring等于该场景的classname
            //pb.gameObject.SetActive(false);

            pb.OnInit(sceneArgs);
            panels.Add(pb.type, pb);
            MaskStyle(pb);
            panelsDethList.Add(pb);
            ChangePanelDeth(pb);
            current = pb;
            pb.OnShowing();
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            go.transform.localRotation = Quaternion.identity;
        }
        StartShowPanel(current, current.PanelShowStyle, true);
    }
Ejemplo n.º 5
0
    public static void PanelSwitch(PanelName panelName)
    {
        EventParamete eventParamete = new EventParamete();

        eventParamete.AddParameter <PanelName>(panelName);
        EventManager.TriggerEvent(GenericEventEnumType.Message, SwitchPanel.PanelToState.ToString(), eventParamete);
    }
Ejemplo n.º 6
0
 /// <summary>
 /// 打开指定弹框
 /// </summary>
 /// <param name="sceneType"></param>
 /// <param name="panelArgs">场景参数</param>
 public void ShowPanel(PanelName panelName, params object[] panelArgs)
 {
     MainPanel.isXIALUO = false;
     if (panels.ContainsKey(panelName))
     {
         LogUtils.Log(LogUtils.LogColor.Red, panelName, " 该面板已打开!");
         current = panels[panelName];
     }
     else
     {
         GameObject go    = new GameObject(panelName.ToString());
         Type       mType = Type.GetType(panelName.ToString());
         PanelBase  pb    = go.AddComponent(mType) as PanelBase; //sceneType.tostring等于该场景的classname
         pb.OnInit(panelArgs);
         pb.isShow = true;
         panels.Add(pb.type, pb);
         MaskStyle(pb);
         panelsDethList.Add(pb);
         ChangePanelDeth(pb);
         current = pb;
         pb.OnShowing();
         go.transform.localPosition = Vector3.zero;
         go.transform.localScale    = Vector3.one;
         go.transform.localRotation = Quaternion.identity;
         StartShowPanel(current, current.PanelShowStyle, true);
     }
 }
Ejemplo n.º 7
0
    public override void OnListenerMessage(EventParamete parameteData)
    {
        //接收监听事件的数据,然后用switch判断做处理

        //除此之外,也可以在这里监听UDP传输的数据,但是接收的数据是子线程数据,要通过队列接收,
        //然后在update转换成主线程数据,才能对数据进行处理

        if (parameteData.EvendName == TransportType.UdpToState.ToString())
        {
            QueueData queueData = parameteData.GetParameter <QueueData>()[0];
            GetVs.Enqueue(queueData);
        }

        if (parameteData.EvendName == TransportType.SwitchPanel.ToString())
        {
            PanelName panelName = parameteData.GetParameter <PanelName>()[0];
            switch (panelName)
            {
            case PanelName.WaitPanel:
                CurrentTask.ChangeTask(new WaitTask(this));
                break;

            case PanelName.DisplayPanel:
                CurrentTask.ChangeTask(new DisplayTask(this));
                break;

            case PanelName.SailingPanel:
                CurrentTask.ChangeTask(new SailingTask(this));
                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 把ui显示在界面上
    /// </summary>
    /// <param name="panelName"></param>
    public BasePanel PushPanel(PanelName panelName, PanelType panelType = PanelType.normalPanel)
    {
        Debug.Log("push" + panelName);
        if (panelDict.TryGetValue(panelName, out BasePanel panel))
        {
            //noticePanel
            if (panelType == PanelType.noticePanel)
            {
                noticePanelStack.Push(panel);
                panel.OnEnter();
                Debug.Log("调用Message");
                return(panel);
            }
            else if (panelType == PanelType.normalPanel)
            {
                if (normalPanelStack.Count > 0)
                {
                    BasePanel topPanel = normalPanelStack.Peek();
                    topPanel.OnPause();
                }

                normalPanelStack.Push(panel);
                panel.OnEnter();
                Debug.Log("调用");
                return(panel);
            }
        }
        else
        {
            BasePanel panelObject = SpawnPanel(panelName);
            if (panelType == PanelType.normalPanel)
            {
                if (normalPanelStack.Count > 0)
                {
                    BasePanel topPanel = normalPanelStack.Peek();
                    topPanel.OnPause();
                }

                normalPanelStack.Push(panelObject);
                panelObject.OnEnter();
                Debug.Log("生成");
                return(panelObject);
            }
            else
            {
                if (noticePanelStack.Count > 0)
                {
                    BasePanel topPanel = noticePanelStack.Peek();
                    topPanel.OnPause();
                }

                noticePanelStack.Push(panelObject);
                panelObject.OnEnter();
                Debug.Log("生成");
                return(panelObject);
            }
        }
        return(null);
    }
Ejemplo n.º 9
0
 public GenericPanelDescriptor(string name, Type viewType, PanelPosition defaultPosition, bool removeOnHide, bool isPinned)
 {
     Name            = PanelName.Parse(name);
     ViewType        = viewType;
     DefaultPosition = defaultPosition;
     RemoveOnHide    = removeOnHide;
     IsPinned        = isPinned;
 }
Ejemplo n.º 10
0
 public void Destroy(PanelName _panelName)
 {
     if (loadedPanel.ContainsKey(_panelName))
     {
         PanelBase tPanelBase = loadedPanel[_panelName];
         tPanelBase.Hide();
         Destroy(tPanelBase);
     }
 }
Ejemplo n.º 11
0
    public void Close(PanelName _panelName)
    {
        PanelBase tPanelBase = loadedPanel[_panelName];

        if (tPanelBase.gameObject.activeSelf)
        {
            tPanelBase.Hide();
        }
    }
Ejemplo n.º 12
0
    public void LoadPanel(PanelName _panelName)
    {
        PanelBase tPanelBase = Resources.Load <PanelBase>("123");

        if (!loadedPanel.ContainsKey(_panelName))
        {
            loadedPanel.Add(_panelName, tPanelBase);
        }
    }
Ejemplo n.º 13
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="name"></param>
        public void ClosePanel(PanelName name)
        {
            PanelBase panel = null;

            if (panels.TryGetValue(name, out panel))
            {
                panel.ClosePanel();
                panels.Remove(name);
            }
        }
Ejemplo n.º 14
0
    public static T GetInstance <T>(PanelName name) where T : PanelInstance
    {
        PanelInstance i = prefabs[name];

        if (!i.instanciated)
        {
            i.OnCreate();
        }
        return((T)i);
    }
Ejemplo n.º 15
0
    public void SceneChange(SceneName sceneName, PanelName panelName)
    {
        EventParamete eventParamete = new EventParamete();

        eventParamete.AddParameter(panelName);
        EventManager.TriggerEvent(GenericEventEnumType.Message, TransportType.SwitchPanel.ToString(), eventParamete);
        SceneSwitch data = new SceneSwitch();

        data.SceneName = sceneName.ToString();
        SendDataToSever(ParmaterCodes.SceneSwitch, data);
    }
Ejemplo n.º 16
0
 public void Open(PanelName _panelName)
 {
     if (loadedPanel.ContainsKey(_panelName))
     {
         PanelBase tPanel = loadedPanel[_panelName];
         tPanel.Show();
     }
     else
     {
         LoadPanel(_panelName);
     }
 }
Ejemplo n.º 17
0
        public void OpenPanel(PanelName panelName)
        {
            for (int i = 0; i < panels.Length; i++)
            {
                panels[i].SetActive(false);
            }

            if (panelName != PanelName.None)
            {
                panels[(int)panelName].SetActive(true);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 创建 Panel
        /// </summary>
        /// <param name="name"></param>
        public PanelBase CreatePanel(PanelName name)
        {
            PanelBase panel = null;

            if (!panels.TryGetValue(name, out panel))
            {
                panel = PanelMap.GetPanel(name);
                panels.Add(name, panel);
            }
            panel.CreatePanel();

            return(panel);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 强制摧毁面板
 /// </summary>
 /// <param name="panel"></param>
 public void DestroyPanel(PanelName type)
 {
     if (panels.ContainsKey(type))
     {
         PanelBase pb = panels[type];
         if (!pb.cache)
         {
             GameObject.Destroy(pb.gameObject);
             panels.Remove(type);
             panelsDethList.Remove(pb);
         }
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 发起关闭
 /// </summary>
 public void HidePanel(PanelName type)
 {
     if (panels.ContainsKey(type))
     {
         PanelBase pb = null;
         pb = panels[type];
         StartShowPanel(pb, pb.PanelShowStyle, false);
         panelsDethList.Remove(pb);
     }
     else
     {
         Debug.LogError("关闭的面板不存在!");
     }
 }
Ejemplo n.º 21
0
    public void HidePanel(PanelName panelName)
    {
        PanelBase panel = GetPanel(panelName);

        if (panel != null)
        {
            if (!panel.skin.activeInHierarchy)
            {
                return;
            }
            panel.skin.SetActive(false);
            panel.OnHide();
        }
    }
Ejemplo n.º 22
0
    public void AddPanel(PanelName panelName, params object[] panelArgs)
    {
        PannelModel pm = new PannelModel();

        pm.pn = panelName;
        pm.po = panelArgs;
        PannelQueue.Enqueue(pm);
        //if (PannelQueue.Count <= 1)
        //{
        //    var p = PannelQueue.Dequeue();
        //    ShowPanel(p.pn, p.po);
        //}
        TestingPannel();
    }
Ejemplo n.º 23
0
    /// <summary>
    /// 隐藏页面
    /// </summary>
    /// <param name="panelName"></param>
    public void HidePanel(PanelName panelName)
    {
        PanelBase panel = GetPanel(panelName);

        if (panel != null)
        {
            if (!panel.curView.activeInHierarchy)
            {
                return;
            }
            RomoveToList(panelName.ToString());
            panel.OnHide();
        }
    }
Ejemplo n.º 24
0
 /// <summary>
 /// 强制摧毁面板
 /// </summary>
 /// <param name="panel"></param>
 public void DestroyPanel(PanelName type)
 {
     if (panels.ContainsKey(type))
     {
         PanelBase pb = panels[type];
         if (!pb.cache)
         {
             pb.isShow = false;
             pb.OnHideDone();
             GameObject.Destroy(pb.gameObject);
             panels.Remove(type);
             panelsDethList.Remove(pb);
         }
     }
 }
Ejemplo n.º 25
0
    public void OpenPanel(PanelName panelNmae, params object[] _args)
    {
        string name = panelNmae.ToString();

        if (dict.ContainsKey(name))
        {
            GetPanel(name).skin.transform.SetAsLastSibling();
            if (GetPanel(name).skin.gameObject.activeInHierarchy)
            {
                return;
            }
            GetPanel(name).skin.SetActive(true);
            GetPanel(name).args = _args;
            GetPanel(name).OnOpen();
            return;
        }
    }
Ejemplo n.º 26
0
 public void PanelReflect(PanelName panelType, MainPack pack, String methodName)
 {
     //查找所需panel
     if (UIManager.Instance.panelDict.TryGetValue(panelType, out BasePanel panel))
     {
         //获取方法
         MethodInfo method = panel.GetType().GetMethod(methodName);
         if (method == null)
         {
             Debug.Log("没有找到对应的处理方法");
             return;
         }
         Debug.Log("找到对应的处理方法" + method);
         //调用方法
         method.Invoke(panel, new object[] { pack });
     }
 }
Ejemplo n.º 27
0
    public override void OnListenerMessage(EventParamete parameteData)
    {
        //接收监听事件的数据,然后用swich判断做处理

        if (parameteData.EvendName == MTFrame.EventType.PanelSwitch.ToString())
        {
            PanelName panelName = parameteData.GetParameter <PanelName>()[0];
            switch (panelName)
            {
            case PanelName.WaitPanel:

                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 28
0
    public void OpenPanel(PanelName panelName)
    {
        if (ActivePanel != null)
        {
            ActivePanel.gameObject.SetActive(false);
        }

        PanelBase Panel = null;

        if (Panels.TryGetValue(panelName, out Panel) != false)
        {
            ActivePanel = Panel;
            Panel.gameObject.SetActive(true);
        }
        else
        {
            Debug.LogError("Panel not found.");
        }
    }
Ejemplo n.º 29
0
    /// <summary>
    /// 用于打开已经打开过的页面隐藏显示或者靠后页面置顶
    /// </summary>
    /// <param name="panelName"></param>
    /// <param name="_args"></param>
    public void OpenHidePanel(PanelName panelName, params object[] _args)
    {
        string name = panelName.ToString();

        if (Paneldict.ContainsKey(name))
        {
            GetPanel(name).curView.transform.SetAsLastSibling();
            if (GetPanel(name).curView.gameObject.activeInHierarchy)
            {
                return;
            }
            GetPanel(name).args = _args;
            GetPanel(name).OnShow();
            return;
        }
        else
        {
            Debug.LogError(panelName.ToString() + ":页面打开失败,页面不存在。尝试使用OpenPanel<T>打开页面");
        }
    }
Ejemplo n.º 30
0
        public static PanelBase GetPanel(PanelName pname)
        {
            switch (pname)
            {
            case PanelName.HudPanel:
                return(new HudPanel());

            case PanelName.LoaderPanel:
                return(new LoaderPanel());

            case PanelName.LoginPanel:
                return(new LoginPanel());

            case PanelName.MainPanel:
                return(new MainPanel());

            default:
                return(null);
            }
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Force Destroy Panel
 /// </summary>
 /// <param name="panel"></param>
 public void DestroyPanel(PanelName type)
 {
     if (panels.ContainsKey(type)){
         PanelBase pb = panels[type];
         if (!pb.cache){
             GameObject.Destroy(pb.gameObject);
             panels.Remove(type);
         }
     }
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Show Panel
 /// </summary>
 /// <param name="sceneType"></param>
 /// <param name="sceneArgs"></param>
 public void ShowPanel(PanelName panelName, params object[] sceneArgs)
 {
     if (panels.ContainsKey(panelName)){
         Debug.LogError("Panel has been shown");
         current = panels[panelName];
         current.gameObject.SetActive(false);
         current.OnInit(sceneArgs);
         current.OnShowing();
         LayerMgr.GetInstance().SetLayer(current.gameObject, LayerType.Panel);
     }
     else{
         GameObject go = new GameObject(panelName.ToString());
         //sceneType.tostring = classname in the current scene
         current = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(go, "Assets/Script/Core/View/PanelMgr.cs (94,14)", panelName.ToString()) as PanelBase;
         current.gameObject.SetActive(false);
         current.OnInit(sceneArgs);
         panels.Add(current.type, current);
         current.OnShowing();
         LayerMgr.GetInstance().SetLayer(current.gameObject, LayerType.Panel);
         go.transform.localPosition = Vector3.zero;
         go.transform.localScale = Vector3.one;
         go.transform.localRotation = Quaternion.identity;
         MaskStyle(current);
     }
     StartShowPanel(current, current.PanelShowStyle,true);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Hide Panel
 /// </summary>
 public void HidePanel(PanelName type)
 {
     if (panels.ContainsKey(type)){
         PanelBase pb = null;
         pb = panels[type];
         StartShowPanel(pb, pb.PanelShowStyle, false);
     }
     else Debug.LogError("Panel doesn't exist");
 }