示例#1
0
/// <summary>
        /// 置顶常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        public void PlaceTopUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        PlaceTopUIEntity(OverlayUIs[type] as UILogicResident);
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        PlaceTopUIEntity(CameraUIs[type] as UILogicResident);
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        WorldUIs[attribute.WorldUIDomainName].PlaceTop(type);
                    }
                    break;
                }
            }
        }
示例#2
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))
                    {
                        DestroyUIEntity(OverlayUIs[type]);
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        DestroyUIEntity(CameraUIs[type]);
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        WorldUIs[attribute.WorldUIDomainName].DestroyUI(type);
                    }
                    break;
                }
            }
        }
示例#3
0
        /// <summary>
        /// 置顶常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        public void PlaceTopUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

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

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        WorldUIs[attribute.WorldUIDomainName].PlaceTop(type);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                    break;
                }
            }
        }
示例#4
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);
        }
示例#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);
        }
示例#6
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);
        }
示例#7
0
        /// <summary>
        /// 打开常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        /// <param name="args">可选参数</param>
        /// <returns>加载协程</returns>
        public Coroutine OpenResidentUI(Type type, params object[] args)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        return(CreateOpenUIEntity(attribute, type.FullName, OverlayUIs[type], _overlayResidentPanel, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        return(CreateOpenUIEntity(attribute, type.FullName, CameraUIs[type], _cameraResidentPanel, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].OpenResidentUI(type, _defineUIAndEntitys.ContainsKey(type.FullName) ? _defineUIAndEntitys[type.FullName] : null, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                }
            }
            return(null);
        }
示例#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))
                    {
                        return(CreateUIEntity(attribute, type.FullName, OverlayUIs[type], _overlayTemporaryPanel));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        return(CreateUIEntity(attribute, type.FullName, CameraUIs[type], _cameraTemporaryPanel));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                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, string.Format("预加载UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                }
            }
            return(null);
        }
示例#9
0
        /// <summary>
        /// 打开非常驻UI
        /// </summary>
        /// <param name="type">非常驻UI逻辑类</param>
        /// <param name="args">可选参数</param>
        /// <returns>加载协程</returns>
        public Coroutine OpenTemporaryUI(Type type, params object[] args)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (OverlayUIs.ContainsKey(type))
                    {
                        if (_currentOverlayTemporaryUI != null && _currentOverlayTemporaryUI.IsOpened)
                        {
                            if (IsLockTemporaryUI)
                            {
                                return(null);
                            }
                            if (!_navigataBackUI)
                            {
                                _temporaryUIStack.Add(_currentOverlayTemporaryUI);
                            }
                            CloseUIEntity(_currentOverlayTemporaryUI);
                            _currentOverlayTemporaryUI = null;
                        }
                        _currentOverlayTemporaryUI = OverlayUIs[type] as UILogicTemporary;

                        return(CreateOpenUIEntity(attribute, type.FullName, OverlayUIs[type], _overlayTemporaryPanel, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        if (_currentCameraTemporaryUI != null && _currentCameraTemporaryUI.IsOpened)
                        {
                            if (IsLockTemporaryUI)
                            {
                                return(null);
                            }

                            CloseUIEntity(_currentCameraTemporaryUI);
                            _currentCameraTemporaryUI = null;
                        }
                        _currentCameraTemporaryUI = CameraUIs[type] as UILogicTemporary;

                        return(CreateOpenUIEntity(attribute, type.FullName, CameraUIs[type], _cameraTemporaryPanel, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].OpenTemporaryUI(type, _defineUIAndEntitys.ContainsKey(type.FullName) ? _defineUIAndEntitys[type.FullName] : null, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, string.Format("打开UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                }
            }
            return(null);
        }
示例#10
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;
                }
            }
        }
示例#11
0
        /// <summary>
        /// 打开非常驻UI
        /// </summary>
        /// <param name="type">非常驻UI逻辑类</param>
        /// <param name="args">可选参数</param>
        /// <returns>加载协程</returns>
        public Coroutine OpenTemporaryUI(Type type, params object[] args)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

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

                        if (_currentOverlayTemporaryUI != null && _currentOverlayTemporaryUI.IsOpened)
                        {
                            if (IsLockTemporaryUI)
                            {
                                return(null);
                            }
                            _currentOverlayTemporaryUI.UIEntity.SetActive(false);
                            _currentOverlayTemporaryUI.OnClose();
                            _currentOverlayTemporaryUI = null;
                        }
                        _currentOverlayTemporaryUI = ui;

                        if (!ui.IsCreated)
                        {
                            return(CreateOpenUIEntity(attribute, type.FullName, ui, _overlayTemporaryPanel, args));
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

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

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

                        if (_currentCameraTemporaryUI != null && _currentCameraTemporaryUI.IsOpened)
                        {
                            if (IsLockTemporaryUI)
                            {
                                return(null);
                            }
                            _currentCameraTemporaryUI.UIEntity.SetActive(false);
                            _currentCameraTemporaryUI.OnClose();
                            _currentCameraTemporaryUI = null;
                        }
                        _currentCameraTemporaryUI = ui;

                        if (!ui.IsCreated)
                        {
                            return(CreateOpenUIEntity(attribute, type.FullName, ui, _cameraTemporaryPanel, args));
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].OpenTemporaryUI(type, _defineUIAndEntitys.ContainsKey(type.FullName) ? _defineUIAndEntitys[type.FullName] : null, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                }
            }
            return(null);
        }