Beispiel #1
0
            /// <summary>
            /// 销毁UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void DestroyUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (ui.IsOpened)
                    {
                        return;
                    }

                    ui.OnDestroy();
                    Destroy(ui.UIEntity);
                    ui.UIEntity = null;
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "销毁UI失败:UI对象 " + type.Name + " 并未存在!");
                }
            }
Beispiel #2
0
            /// <summary>
            /// 预加载非常驻UI
            /// </summary>
            /// <param name="type">非常驻UI逻辑类</param>
            /// <param name="entity">UI实体</param>
            /// <returns>加载协程</returns>
            public Coroutine PreloadingTemporaryUI(Type type, GameObject entity)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        if (entity != null)
                        {
                            ui.UIEntity = Instantiate(entity, _worldTemporaryPanel);
                            ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                            ui.OnInit();
                            return(null);
                        }
                        else
                        {
                            return(Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldTemporaryPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                                ui.OnInit();
                            }, true));
                        }
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "预加载UI失败:UI对象 " + type.Name + " 并未存在!");
                }
                return(null);
            }
Beispiel #3
0
            /// <summary>
            /// 销毁UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void DestroyUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (ui.IsOpened)
                    {
                        return;
                    }

                    ui.OnDestroy();
                    Destroy(ui.UIEntity);
                    ui.UIEntity = null;
                }
                else
                {
                    GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                }
            }
Beispiel #4
0
        /// <summary>
        /// 预加载常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        /// <param name="entity">UI实体</param>
        /// <returns>加载协程</returns>
        public Coroutine PreloadingResidentUI(Type type, GameObject entity)
        {
            if (_worldUIs.ContainsKey(type))
            {
                UILogicBase ui = _worldUIs[type];

                if (ui.IsCreated)
                {
                    return(null);
                }

                if (entity != null)
                {
                    ui.UIEntity = Main.Clone(entity, _worldResidentPanel);
                    ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                    ui.OnInit();
                    return(null);
                }
                else
                {
                    return(Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldResidentPanel, null, (obj) =>
                    {
                        ui.UIEntity = obj;
                        ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                        ui.OnInit();
                    }, true));
                }
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取已经打开的UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        /// <returns>UI逻辑对象</returns>
        public UILogicBase GetOpenedUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = OverlayUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "获取UI失败:UI对象 " + type.Name + " 并未存在,或并未打开!");
                    }

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = CameraUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "获取UI失败:UI对象 " + type.Name + " 并未存在,或并未打开!");
                    }

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].GetOpenedUI(type));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "获取UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                }
            }
            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// 获取已经打开的UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        /// <returns>UI逻辑对象</returns>
        public UILogicBase GetOpenedUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = OverlayUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = CameraUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].GetOpenedUI(type));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            return(null);
        }
Beispiel #7
0
        /// <summary>
        /// 销毁UI实体
        /// </summary>
        /// <param name="uILogic">UI逻辑类对象</param>
        private void DestroyUIEntity(UILogicBase uILogic)
        {
            if (!uILogic.IsCreated)
            {
                return;
            }

            uILogic.OnDestroy();
            Main.Kill(uILogic.UIEntity);
            uILogic.UIEntity = null;
        }
Beispiel #8
0
        /// <summary>
        /// 预加载非常驻UI
        /// </summary>
        /// <param name="type">非常驻UI逻辑类</param>
        /// <returns>加载协程</returns>
        public Coroutine PreloadingTemporaryUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = OverlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return(CreateUIEntity(attribute, type.FullName, ui, _overlayTemporaryPanel));
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "预加载UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = CameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return(CreateUIEntity(attribute, type.FullName, ui, _cameraTemporaryPanel));
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "预加载UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].PreloadingTemporaryUI(type, _defineUIAndEntitys.ContainsKey(type.FullName) ? _defineUIAndEntitys[type.FullName] : null));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "预加载UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                }
            }
            return(null);
        }
Beispiel #9
0
        /// <summary>
        /// 关闭UI实体
        /// </summary>
        /// <param name="uILogic">UI逻辑类对象</param>
        private void CloseUIEntity(UILogicBase uILogic)
        {
            if (!uILogic.IsCreated)
            {
                return;
            }

            if (!uILogic.IsOpened)
            {
                return;
            }

            uILogic.UIEntity.SetActive(false);
            uILogic.OnClose();
        }
Beispiel #10
0
        /// <summary>
        /// 销毁UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void DestroyUI(Type type)
        {
            if (_worldUIs.ContainsKey(type))
            {
                UILogicBase ui = _worldUIs[type];

                if (!ui.IsCreated)
                {
                    return;
                }

                ui.OnDestroy();
                Main.Kill(ui.UIEntity);
                ui.UIEntity = null;
            }
        }
Beispiel #11
0
            /// <summary>
            /// 销毁域
            /// </summary>
            public void OnTermination()
            {
                foreach (var ui in _worldUIs)
                {
                    UILogicBase uiLogic = ui.Value;

                    if (!uiLogic.IsCreated)
                    {
                        continue;
                    }

                    uiLogic.OnDestroy();
                    Destroy(uiLogic.UIEntity);
                    uiLogic.UIEntity = null;
                }
                _worldUIs.Clear();

                Destroy(_worldUIRoot.gameObject);
            }
Beispiel #12
0
            /// <summary>
            /// 获取已经打开的UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            /// <returns>UI逻辑对象</returns>
            public UILogicBase GetOpenedUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (ui.IsOpened)
                    {
                        return(ui);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "获取UI失败:UI对象 " + type.Name + " 并未存在,或并未打开!");
                }
            }
Beispiel #13
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void CloseUI(Type type)
        {
            if (_worldUIs.ContainsKey(type))
            {
                UILogicBase ui = _worldUIs[type];

                if (!ui.IsCreated)
                {
                    return;
                }

                if (!ui.IsOpened)
                {
                    return;
                }

                ui.UIEntity.SetActive(false);
                ui.OnClose();
            }
        }
Beispiel #14
0
        /// <summary>
        /// 获取已经打开的UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        /// <returns>UI逻辑对象</returns>
        public UILogicBase GetOpenedUI(Type type)
        {
            if (_worldUIs.ContainsKey(type))
            {
                UILogicBase ui = _worldUIs[type];

                if (ui.IsOpened)
                {
                    return(ui);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #15
0
            /// <summary>
            /// 获取已经打开的UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            /// <returns>UI逻辑对象</returns>
            public UILogicBase GetOpenedUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (ui.IsOpened)
                    {
                        return(ui);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    GlobalTools.LogError(string.Format("获取UI失败:UI对象 {0} 并未存在,或并未打开!", type.Name));
                    return(null);
                }
            }
Beispiel #16
0
        public override void OnTermination()
        {
            base.OnTermination();

            foreach (KeyValuePair <Type, UILogicBase> ui in _overlayUIs)
            {
                UILogicBase uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    continue;
                }

                uiLogic.OnDestroy();
                Destroy(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            _overlayUIs.Clear();

            foreach (KeyValuePair <Type, UILogicBase> ui in _cameraUIs)
            {
                UILogicBase uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    continue;
                }

                uiLogic.OnDestroy();
                Destroy(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            _cameraUIs.Clear();

            foreach (KeyValuePair <string, WorldUIDomain> ui in _worldUIs)
            {
                ui.Value.Termination();
            }
            _worldUIs.Clear();
        }
Beispiel #17
0
        /// <summary>
        /// 终结助手
        /// </summary>
        public void OnTermination()
        {
            _defineUIAndEntitys.Clear();

            foreach (var ui in OverlayUIs)
            {
                UILogicBase uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    continue;
                }

                uiLogic.OnDestroy();
                Main.Kill(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            OverlayUIs.Clear();

            foreach (var ui in CameraUIs)
            {
                UILogicBase uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    continue;
                }

                uiLogic.OnDestroy();
                Main.Kill(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            CameraUIs.Clear();

            foreach (var ui in WorldUIs)
            {
                ui.Value.OnTermination();
            }
            WorldUIs.Clear();
        }
Beispiel #18
0
            /// <summary>
            /// 预加载非常驻UI
            /// </summary>
            /// <param name="type">非常驻UI逻辑类</param>
            /// <returns>加载协程</returns>
            public Coroutine PreloadingTemporaryUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return(Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldTemporaryPanel, null, (obj) =>
                        {
                            ui.UIEntity = obj;
                            ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                            ui.OnInit();
                        }, true));
                    }
                }
                else
                {
                    GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
                }
                return(null);
            }
Beispiel #19
0
            /// <summary>
            /// 关闭UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void CloseUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (!ui.IsOpened)
                    {
                        return;
                    }

                    ui.UIEntity.SetActive(false);
                    ui.OnClose();
                }
                else
                {
                    GlobalTools.LogError(string.Format("关闭UI失败:UI对象 {0} 并未存在!", type.Name));
                }
            }
Beispiel #20
0
            /// <summary>
            /// 关闭UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void CloseUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicBase ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (!ui.IsOpened)
                    {
                        return;
                    }

                    ui.UIEntity.SetActive(false);
                    ui.OnClose();
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "关闭UI失败:UI对象 " + type.Name + " 并未存在!");
                }
            }
Beispiel #21
0
 /// <summary>
 /// 应用UI逻辑类的数据绑定
 /// </summary>
 /// <param name="uILogicBase">UI逻辑实例</param>
 /// <param name="fieldInfos">所有自动化字段</param>
 public static void ApplyDataBinding(UILogicBase uILogicBase, FieldInfo[] fieldInfos)
 {
     ApplyDataBinding(uILogicBase, uILogicBase, fieldInfos);
 }
Beispiel #22
0
        /// <summary>
        /// 创建并打开UI实体
        /// </summary>
        /// <param name="uIResource">UI资源标记</param>
        /// <param name="uITypeName">UI逻辑类型</param>
        /// <param name="uILogic">UI逻辑类对象</param>
        /// <param name="uIParent">UI的父级</param>
        /// <param name="args">UI打开的参数</param>
        /// <returns>加载协程</returns>
        private Coroutine CreateOpenUIEntity(UIResourceAttribute uIResource, string uITypeName, UILogicBase uILogic, Transform uIParent, params object[] args)
        {
            if (uILogic.IsOpened)
            {
                return(null);
            }

            if (!uILogic.IsCreated)
            {
                if (_defineUIAndEntitys.ContainsKey(uITypeName) && _defineUIAndEntitys[uITypeName] != null)
                {
                    uILogic.UIEntity = Main.Clone(_defineUIAndEntitys[uITypeName], uIParent);
                    uILogic.UIEntity.SetActive(true);
                    uILogic.OnInit();
                    uILogic.OnOpen(args);
                    PlaceTopUIEntity(uILogic as UILogicResident);
                    return(null);
                }
                else
                {
                    return(Main.m_Resource.LoadPrefab(new PrefabInfo(uIResource), uIParent, null, (obj) =>
                    {
                        uILogic.UIEntity = obj;
                        uILogic.UIEntity.SetActive(true);
                        uILogic.OnInit();
                        uILogic.OnOpen(args);
                        PlaceTopUIEntity(uILogic as UILogicResident);
                    }, true));
                }
            }
            else
            {
                uILogic.UIEntity.SetActive(true);
                uILogic.OnOpen(args);
                PlaceTopUIEntity(uILogic as UILogicResident);
                return(null);
            }
        }
Beispiel #23
0
 /// <summary>
 /// 创建UI实体
 /// </summary>
 /// <param name="uIResource">UI资源标记</param>
 /// <param name="uITypeName">UI逻辑类型</param>
 /// <param name="uILogic">UI逻辑类对象</param>
 /// <param name="uIParent">UI的父级</param>
 /// <returns>加载协程</returns>
 private Coroutine CreateUIEntity(UIResourceAttribute uIResource, string uITypeName, UILogicBase uILogic, Transform uIParent)
 {
     if (_defineUIAndEntitys.ContainsKey(uITypeName) && _defineUIAndEntitys[uITypeName] != null)
     {
         uILogic.UIEntity = Main.Clone(_defineUIAndEntitys[uITypeName], uIParent);
         uILogic.UIEntity.SetActive(false);
         uILogic.OnInit();
         return(null);
     }
     else
     {
         return(Main.m_Resource.LoadPrefab(new PrefabInfo(uIResource), uIParent, null, (obj) =>
         {
             uILogic.UIEntity = obj;
             uILogic.OnInit();
         }, true));
     }
 }
Beispiel #24
0
        /// <summary>
        /// 销毁UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void DestroyUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = OverlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Main.Kill(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "销毁UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = CameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Main.Kill(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "销毁UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        WorldUIs[attribute.WorldUIDomainName].DestroyUI(type);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "销毁UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                    break;
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// 预加载非常驻UI
        /// </summary>
        /// <param name="type">非常驻UI逻辑类</param>
        /// <returns>加载协程</returns>
        public Coroutine PreloadingTemporaryUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (_overlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _overlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return(Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _overlayTemporaryPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.OnInit();
                            }, true));
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.Camera:
                    if (_cameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _cameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return(Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _cameraTemporaryPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.OnInit();
                            }, true));
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(_worldUIs[attribute.WorldUIDomainName].PreloadingTemporaryUI(type));
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                    break;
                }
            }
            return(null);
        }
Beispiel #26
0
        /// <summary>
        /// 获取已经打开的UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        /// <returns>UI逻辑对象</returns>
        public UILogicBase GetOpenedUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (_overlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _overlayUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("获取UI失败:UI对象 {0} 并未存在,或并未打开!", type.Name));
                        return(null);
                    }

                case UIType.Camera:
                    if (_cameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _cameraUIs[type];

                        if (ui.IsOpened)
                        {
                            return(ui);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("获取UI失败:UI对象 {0} 并未存在,或并未打开!", type.Name));
                        return(null);
                    }

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(_worldUIs[attribute.WorldUIDomainName].GetOpenedUI(type));
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("获取UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                        return(null);
                    }
                }
            }
            return(null);
        }
Beispiel #27
0
 /// <summary>
 /// 应用UI逻辑类的对象路径定义
 /// </summary>
 /// <param name="uILogicBase">UI逻辑实例</param>
 /// <param name="fieldInfos">所有自动化字段</param>
 public static void ApplyObjectPath(UILogicBase uILogicBase, FieldInfo[] fieldInfos)
 {
     ApplyObjectPath(uILogicBase, uILogicBase.UIEntity, fieldInfos);
 }
Beispiel #28
0
        /// <summary>
        /// 销毁UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void DestroyUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (_overlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _overlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Destroy(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.Camera:
                    if (_cameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _cameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Destroy(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        _worldUIs[attribute.WorldUIDomainName].DestroyUI(type);
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                    break;
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void CloseUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (_overlayUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _overlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.SetActive(false);
                        ui.OnClose();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "关闭UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.Camera:
                    if (_cameraUIs.ContainsKey(type))
                    {
                        UILogicBase ui = _cameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.SetActive(false);
                        ui.OnClose();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "关闭UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        _worldUIs[attribute.WorldUIDomainName].CloseUI(type);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "关闭UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                    break;
                }
            }
        }