/// <summary> /// 执行 /// </summary> private IEnumerator <float> Run() { if (_taskDict.Count == 0) { yield break; } //ReCoroutine[] tasks = new ReCoroutine[task_dep_dict.Count]; for (int i = 0; i < _taskDict.Count; i++) { //按顺序执行 yield return(ReCoroutine.Wait(_taskDict.GetValueAt(i).GetCoroutine())); } }
/// <summary> /// 执行 /// </summary> private IEnumerator <float> Run() { if (IsDone) { yield break; } // 1.根据依赖任务转换成协同,并且同时执行所有协同 var tasks = new ReCoroutine[task_dep_dict.Count]; int length = task_dep_dict.Count; for (int i = 0; i < length; i++) { tasks[i] = task_dep_dict.GetValueAt(i).GetCoroutine(); } // 同时执行所有的任务 yield return(ReCoroutine.WaitForAllCoroutines(tasks)); // 2.任务==同步类型,那么执行同步操作 if (ActionType == E_TaskActionType.sync) { length = _sync_actions.Count; //同步按顺序执行 for (int i = 0; i < length; i++) { _sync_actions[i](); } } else // 3.任务==异步类型,执行异步任务 { length = _asyn_actions.Count; //异步按顺序执行 for (int i = 0; i < length; i++) { yield return(ReCoroutine.Wait(_asyn_actions[i])); } } IsDone = true; }