Example #1
0
        /// <summary>
        /// 添加一个新任务
        /// </summary>
        public CoroutineTask AddTask(IEnumerator ienumer, Action <bool> call_back = null, object bind_object = null, bool auto_start = true)
        {
            CoroutineTask task = new CoroutineTask(ienumer, call_back, bind_object, auto_start);

            AddTask(task);
            return(task);
        }
Example #2
0
        public CoroutineTask WaitSecondTodo(Action <bool> call_back, float wait_time, object bind_object = null)
        {
            IEnumerator   ienumer = _do_wait_to_do(wait_time);
            CoroutineTask task    = new CoroutineTask(ienumer, call_back, bind_object);

            AddTask(task);
            return(task);
        }
Example #3
0
        /// <summary>
        /// 当满足条件循环动作
        /// </summary>
        public CoroutineTask LoopTodoByCondition(Action call_back, float interval,
                                                 Func <bool> predicates, object bind_object = null, float start_time = 0)
        {
            IEnumerator   ienumer = _do_loop_by_condition(interval, predicates, call_back, start_time);
            CoroutineTask task    = new CoroutineTask(ienumer, null, bind_object);

            AddTask(task);
            return(task);
        }
Example #4
0
        /// <summary>
        /// 每帧进行循环
        /// </summary>
        public CoroutineTask LoopByEveryFrame(Action call_back, int loop_time = -1
                                              , object bind_object            = null, float delay_time = 0)
        {
            IEnumerator   ienumer = _do_loop_by_every_frame(loop_time, call_back, delay_time);
            CoroutineTask task    = new CoroutineTask(ienumer, null, bind_object);

            AddTask(task);
            return(task);
        }
Example #5
0
        /// <summary>
        /// 间隔时间进行多次动作
        /// </summary>
        public CoroutineTask LoopTodoByTime(Action call_back, float interval
                                            , int loop_count, object bind_object = null, float delay_time = 0)
        {
            IEnumerator   ienumer = _do_loop_by_time(interval, call_back, loop_count, delay_time);
            CoroutineTask task    = new CoroutineTask(ienumer, null, bind_object);

            AddTask(task);
            return(task);
        }
Example #6
0
        public void _re_start(string task_name)
        {
            if (!task_list.ContainsKey(task_name))
            {
                LogManager.Error("重新开始任务,不存在该任务[{0}]", task_name);
                return;
            }
            CoroutineTask task = task_list[task_name];

            Stop(task_name);
            AddTask(task);
        }
Example #7
0
 /// <summary>
 /// 添加一个新任务
 /// </summary>
 public CoroutineTask AddTask(CoroutineTask task)
 {
     if (task_list.ContainsKey(task.Name))
     {
         LogManager.Error("添加新任务,任务[{0}]重名!", task.Name);
         _re_start(task.Name);
     }
     else
     {
         task_list.Add(task.Name, task);
     }
     return(task);
 }
Example #8
0
 /// <summary>
 /// 添加一个新任务
 /// </summary>
 public void AddTask(string task_name, IEnumerator ienumer, Action <bool> call_back = null, object bind_object = null, bool auto_start = true)
 {
     if (task_list.ContainsKey(task_name))
     {
         LogManager.Error("添加新任务,任务[{0}]重名!", task_name);
         _re_start(task_name);
     }
     else
     {
         CoroutineTask task = new CoroutineTask(task_name, ienumer, call_back, bind_object, auto_start);
         task_list.Add(task_name, task);
     }
 }
Example #9
0
        /// <summary>
        /// 当条件成立时等待
        /// </summary>
        public CoroutineTask WaitWhileTodo(Action call_back, Func <bool> conditions, object bind_object = null)
        {
            Action <bool> call_back2 = (bo) =>
            {
                if (bo)
                {
                    call_back();
                }
            };
            CoroutineTask task = new CoroutineTask(_do_wait_while(conditions), call_back2, bind_object);

            AddTask(task);
            return(task);
        }
Example #10
0
        /// <summary>
        /// 等待一段时间再执行回调
        /// </summary>
        public CoroutineTask WaitSecondTodo(Action call_back, float wait_time, object bind_object = null)
        {
            // ReSharper disable once RedundantLambdaSignatureParentheses
            Action <bool> call_back2 = (bo) =>
            {
                if (bo)
                {
                    call_back();
                }
            };
            CoroutineTask task = new CoroutineTask(_do_wait_to_do(wait_time), call_back2, bind_object);

            AddTask(task);
            return(task);
        }
Example #11
0
        /// <summary>
        /// 等到下一帧
        /// </summary>
        public CoroutineTask WaitFrameEnd(Action call_back, object bind_object = null)
        {
            Action <bool> call_back2 = (bo) =>
            {
                if (bo)
                {
                    call_back();
                }
            };
            CoroutineTask task = new CoroutineTask(
                _do_wait_frame_end_to_do(),
                call_back2, bind_object);

            AddTask(task);
            return(task);
        }