コード例 #1
0
        private void CommonUpdate()
        {
            CurrentTime += ReCoroutineManager.GetDeltaTime(this);

            // 1.是否处于等待
            if (!IsWaiting())
            {
                // 2.判断是否结束
                if (!Ie.MoveNext())
                {
                    IsDone = true;
                }
                // 3.更新等待时间
                _update_wait_time(Ie.Current);

                if (Ie.Current.Equals(float.NaN))
                {
                    WaitingCoroutine = ReplaceCoroutine;
                }
            }
            else
            {
                if (WaitingCoroutine != null && WaitingCoroutine.IsDone)
                {
                    WaitingCoroutine = null;
                }
            }
        }
コード例 #2
0
 /// <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()));
     }
 }
コード例 #3
0
        /// <summary>
        /// 间隔时间
        /// </summary>
        public static float GetDeltaTime(ReCoroutine coroutine)
        {
            switch (coroutine.ECoroutineType)
            {
            case E_CoroutineType.update:
                return(update_delta_time);

            case E_CoroutineType.late_update:
                return(late_update_delta_time);

            case E_CoroutineType.fixed_update:
                return(fixed_update_delta_time);

            default:
                return(0);
            }
        }
コード例 #4
0
        public ReCoroutine _internal_add_coroutine(IEnumerator <float> e, E_CoroutineType type = E_CoroutineType.update)
        {
            ReCoroutine cor = new ReCoroutine(e, type);

            if (type == E_CoroutineType.update)
            {
                update_ienumerator_list.Add(cor);
            }
            else if (type == E_CoroutineType.late_update)
            {
                late_update_ienumerator_list.Add(cor);
            }
            else if (type == E_CoroutineType.fixed_update)
            {
                fixed_update_ienumerator_list.Add(cor);
            }

            return(cor);
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
 /// <summary>
 /// 等待其他协程
 /// </summary>
 public static float Wait(ReCoroutine coroutine)
 {
     lock (lock_object)
         ReplaceCoroutine = coroutine;
     return(float.NaN);
 }