Пример #1
0
        /// <summary>
        /// 开启一个UITask
        /// </summary>
        /// <param name="intent"></param>
        /// <param name="onPrepareEnd"></param>
        /// <param name="onViewUpdateComplete"></param>
        /// <param name="redirectOnLoadAllAssetsComplete"></param>
        /// <returns></returns>
        public bool StartUITask(UIIntent intent, Action <bool> onPrepareEnd = null, Action onViewUpdateComplete = null, Action redirectOnLoadAllAssetsComplete = null)
        {
            if (!m_uiTaskRegistyerItemDic.ContainsKey(intent.Name))
            {
                Debug.LogError("StartUITask can't find UITaskRegisterItem name:" + intent.Name);
                return(false);
            }
            var uiTaskRegisterItem = m_uiTaskRegistyerItemDic[intent.Name];
            var uiTask             = CreateOrGetUITaskInstance(uiTaskRegisterItem);

            if (uiTask == null)
            {
                Debug.LogError("StartUITask Can't create UITask instance, typeFullName:" + uiTaskRegisterItem.TypeFullName);
            }
            if (redirectOnLoadAllAssetsComplete != null)
            {
                uiTask.UpdateCtx.SetRedirectOnLoadAssetComplete(redirectOnLoadAllAssetsComplete);
            }
            if (onViewUpdateComplete != null)
            {
                uiTask.UpdateCtx.m_onViewUpdateComplete = onViewUpdateComplete;
            }
            StartUITaskInternal(uiTask, intent, onPrepareEnd);
            return(true);
        }
Пример #2
0
 protected virtual bool OnResume(UIIntent intent)
 {
     StartUpdateUITask(intent);
     if (MainLayer != null)
     {
         SceneTree.Instance.PushLayer(MainLayer);
     }
     return(true);
 }
Пример #3
0
        /// <summary>
        /// 更新UITask
        /// </summary>
        /// <param name="intent"></param>
        protected void StartUpdateUITask(UIIntent intent = null)
        {
            if (intent != null)
            {
                if ((m_modeDefines.Count != 0 || !string.IsNullOrEmpty(intent.Mode)) && !m_modeDefines.Contains(intent.Mode))
                {
                    Debug.LogError(string.Format("{0}'s modeDefines dont contain {1}", this.GetType().Name, intent.Mode));
                }
                OnIntentChange(m_curUIIntent, intent);
                m_curUIIntent = intent;
            }
            bool isNeedUpdateCache = IsNeedUpdateCache();

            if (isNeedUpdateCache)
            {
                UpdateCache();
            }
            bool isNeedLoadLayer  = IsNeedLoadLayer();
            bool isNeedLoadAssets = IsNeedLoadAssets();

            if (isNeedLoadLayer || isNeedLoadAssets)
            {
                bool isLoadUILayerComplete = !isNeedLoadLayer;
                bool isLoadAssetsComplete  = !isNeedLoadAssets;
                if (isNeedLoadLayer)
                {
                    LoadLayer(() =>
                    {
                        isLoadUILayerComplete = true;
                        if (isLoadUILayerComplete && isLoadAssetsComplete)
                        {
                            OnLoadUILayersAndAssetsComplete();
                        }
                    });
                }
                if (isNeedLoadAssets)
                {
                    LoadAssets(() =>
                    {
                        isLoadAssetsComplete = true;
                        if (isLoadUILayerComplete && isLoadAssetsComplete)
                        {
                            OnLoadUILayersAndAssetsComplete();
                        }
                    });
                }
            }
            else
            {
                StartUpdateView();
            }
        }
Пример #4
0
 /// <summary>
 /// 开启UITask
 /// </summary>
 /// <param name="uiTask"></param>
 /// <param name="intent"></param>
 /// <param name="onPrepareEnd"></param>
 private void StartUITaskInternal(UITask uiTask, UIIntent intent, Action <bool> onPrepareEnd = null)
 {
     uiTask.PrapareDataForStart((res) => {
         if (onPrepareEnd != null)
         {
             onPrepareEnd(res);
         }
         if (res)
         {
             StartOrResumeUITask(uiTask, intent);
         }
         else
         {
             Debug.LogError(string.Format("PrapareDataForStart Failed UITask Name:", uiTask.Name));
         }
     });
 }
Пример #5
0
        private void StartOrResumeUITask(UITask uiTask, UIIntent intent)
        {
            switch (uiTask.State)
            {
            case TaskState.Init:
                uiTask.UpdateCtx.m_isInit = true;
                uiTask.EventOnStop       += () => { OnUITaskStop(uiTask); };
                uiTask.EventOnStart      += () => { OnUITaskStart(uiTask); };
                uiTask.Start(intent);
                break;

            case TaskState.Paused:
                uiTask.UpdateCtx.m_isResume = true;
                uiTask.Resume(intent);
                break;

            case TaskState.Runing:
                uiTask.OnNewIntent(intent);
                break;
            }
        }
Пример #6
0
 public UIIntent(string name, UIIntent prevIntent = null, string mode = "")
 {
     m_name       = name;
     m_prevIntent = prevIntent;
     m_mode       = mode;
 }
Пример #7
0
 protected virtual void OnIntentChange(UIIntent prevIntent, UIIntent curIntent)
 {
 }
Пример #8
0
 protected virtual bool OnStart(UIIntent intent)
 {
     StartUpdateUITask(intent);
     return(true);
 }
Пример #9
0
 public void OnNewIntent(UIIntent intent)
 {
     StartUpdateUITask(intent);
 }