示例#1
0
        public bool RemoveFunctionChain(string key, JobTodo Todo = null, JobToDoCondition toDoCheck = null,
                                        JobAutoDropCondition autoDropCondition = null, bool isExecuteImmediately = true)
        {
            JobRepeatBase Job = JobList.Find(job => job.key.Equals(key));

            if (Job == null)
            {
                return(false);
            }

            StopCoroutine(Job.worker);

            Job.jobTodo          -= Todo;
            Job.jobToDoCheck     -= toDoCheck;
            Job.jobAutoDropCheck -= autoDropCondition;

            if (Job.jobTodo == null)
            {
                Job.state = JOB_STATE.JOB_EMPTY;
                return(true);
            }

            if (isExecuteImmediately)
            {
                Job.state = JOB_STATE.JOB_STANDBY;
                StartCoroutine(Job.worker);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Job RepeatManager > Adding Job
        /// <para>key = JobKeyName,
        /// todo = ExecuteFunctionPointer,
        /// delay = Update Sequence Delay(Seconds),
        /// repeatCount = Total Execute Count,
        /// parameter = params object[] : Your Parameter
        /// todoCondition = Execute Condition(true = Available Execute, false = Block Execute),
        /// autoDropCondition = Job Drop Condition(Flag : true = Drop, false = MoveNext)</para>
        /// </summary>
        public bool AddDelegateJob(string key, JobTodo toDo, float delay = 1.0f, int repeatCount = 0, object[] parameter = null,
                                   JobEndAction endActionWhenDrop        = null,
                                   JobToDoCondition toDoCondition        = null, JobAutoDropCondition autoDropCondition = null, bool isImmediately = true)
        {
            // Already Registered Job Check
            if (JobList.Find(job => job.key.Equals(key)) != null)
            {
                return(false);
            }

            GameObject JobObject = new GameObject(key);

            JobObject.transform.parent = this.transform;
            JobRepeatBase newJob = JobObject.AddComponent <JobRepeatBase>();

            newJob.key              = key;
            newJob.jobCoroutine     = null;
            newJob.jobTodo          = toDo;
            newJob.repeatDelay      = delay;
            newJob.repeatCount      = repeatCount;
            newJob.excuteCount      = 0;
            newJob.jobToDoCheck     = toDoCondition;
            newJob.jobAutoDropCheck = autoDropCondition;
            newJob.jobEndAction     = endActionWhenDrop;
            newJob.state            = JOB_STATE.JOB_STANDBY;
            newJob.worker           = CoJobHandle(key);
            newJob.parameter        = parameter;

            if (toDo == null)
            {
                Debug.LogWarningFormat("Are You Sure Adding Empty Job? Todo Parameter is null (key:{0})", key);
                newJob.state = JOB_STATE.JOB_EMPTY;
            }

            newJob.repeatDelay = newJob.repeatDelay < m_MinDelayTime ? m_MinDelayTime : newJob.repeatDelay;
            JobList.Add(newJob);

            if (isImmediately)
            {
                StartCoroutine(newJob.worker);
            }

            return(true);
        }