Ejemplo n.º 1
0
        /// <summary>
        /// 添加一个新任务
        /// </summary>
        public ReCoroutineTask AddTask(IEnumerator <float> ienumer,
                                       Action <bool> callBack = null, object bindObject = null, bool autoStart = true)
        {
            ReCoroutineTask task = new ReCoroutineTask(ienumer, callBack, bindObject, autoStart);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 当满足条件循环动作
        /// </summary>
        public ReCoroutineTask LoopTodoByWhile(Action callBack, float interval, Func <bool> predicates,
                                               object bindObject = null, float startTime = 0)
        {
            ReCoroutineTask task = new ReCoroutineTask(
                DoLoopByWhile(interval, predicates, callBack, startTime), null, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 间隔时间进行多次动作
        /// </summary>
        public ReCoroutineTask LoopTodoByTime(Action callBack, float interval,
                                              int loopTime, object bindObject = null, float startTime = 0)
        {
            ReCoroutineTask task = new ReCoroutineTask(
                DoLoopByTime(interval, loopTime, callBack, startTime), null, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 每帧进行循环
        /// </summary>
        public ReCoroutineTask LoopByEveryFrame(Action callBack, int loopTime = -1
                                                , object bindObject           = null, float startTime = 0)
        {
            ReCoroutineTask task = new ReCoroutineTask(
                DoLoopByEveryFrame(loopTime, callBack, startTime), null, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 等待一段时间再执行时间
        /// </summary>
        public ReCoroutineTask WaitSecondTodo(Action <bool> callBack, float time, object bindObject = null)
        {
            ReCoroutineTask task = new ReCoroutineTask(
                DoWaitTodo(time),
                callBack, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 6
0
        public void Restart(string taskName)
        {
            if (!_taskList.ContainsKey(taskName))
            {
                LogManager.Error("重新开始任务", "不存在该任务" + taskName);
                return;
            }
            ReCoroutineTask task = _taskList[taskName];

            Stop(taskName);
            AddTask(task);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加一个新任务
 /// </summary>
 public ReCoroutineTask AddTask(ReCoroutineTask task)
 {
     if (_taskList.ContainsKey(task.Name))
     {
         //Debug.logger.LogError("添加新任务", "任务重名!" + task.name);
         Restart(task.Name);
     }
     else
     {
         _taskList.Add(task.Name, task);
     }
     return(task);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加一个新任务
 /// </summary>
 public ReCoroutineTask AddTask(string taskName, IEnumerator <float> ienumer,
                                Action <bool> callBack = null, object bindObject = null, bool autoStart = true)
 {
     if (_taskList.ContainsKey(taskName))
     {
         //Debug.logger.LogError("添加新任务", "任务重名!" + taskName);
         Restart(taskName);
         return(_taskList[taskName]);
     }
     else
     {
         ReCoroutineTask task = new ReCoroutineTask(taskName, ienumer, callBack, bindObject, autoStart);
         _taskList.Add(taskName, task);
         return(task);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 当条件成立时等待
        /// </summary>
        public ReCoroutineTask WaitWhileTodo(Action callBack, Func <bool> predicates,
                                             object bindObject = null)
        {
            Action <bool> callBack2 = (bo) =>
            {
                if (bo)
                {
                    callBack();
                }
            };
            ReCoroutineTask task = new ReCoroutineTask(
                DoWaitWhile(predicates), callBack2, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 等待所有其他携程任务完成
        /// </summary>
        public ReCoroutineTask WaitForAllCoroutine(Action callBack, ReCoroutineTask[] tasks,
                                                   object bindObject = null)
        {
            // ReSharper disable once RedundantLambdaSignatureParentheses
            Action <bool> callBack2 = (bo) =>
            {
                if (bo)
                {
                    callBack();
                }
            };
            ReCoroutineTask task = new ReCoroutineTask(
                DoWaitForAllCoroutine(tasks), callBack2, bindObject);

            AddTask(task);
            return(task);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 等待一段时间再执行时间
        /// </summary>
        public ReCoroutineTask WaitSecondTodo(Action callBack, float time, object bindObject = null)
        {
            // ReSharper disable once RedundantLambdaSignatureParentheses
            Action <bool> callBack2 = (bo) =>
            {
                if (bo)
                {
                    callBack();
                }
            };
            ReCoroutineTask task = new ReCoroutineTask(
                DoWaitTodo(time),
                callBack2, bindObject);

            AddTask(task);
            return(task);
        }