Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="work">work的创建和销毁由外界处理</param>
        /// <param name="run"></param>
        /// <returns></returns>
        public void AddWork(IWork work, bool run = false)
        {
            if (work != null && !allWorks.Contains(work))
            {
                allWorks.Add(work);

                if (run)
                {
                    if (runningCount < runningWorks.Count)
                    {
                        runningWorks[runningCount++] = work;
                    }
                    else
                    {
                        runningWorks.Add(work);
                        runningCount++;
                    }

                    work.Start();
                    (work as ITick).Tick(0);                    //有些需要立即生效
                    if (work.IsFinished())
                    {
                        allWorks.Remove(work);
                        runningWorks.Remove(work);
                        runningCount--;
                    }
                }
            }
        }
Exemple #2
0
 public virtual void Tick(float deltaTime)
 {
     if (state == ManagerState.BOOT_LOADING && (bootLoader == null || bootLoader.IsFinished()))
     {
         bootLoader = null;
         state      = ManagerState.RUNNING;
     }
     OnTick(deltaTime);
 }
Exemple #3
0
 protected override WorkState CanChangeState(WorkState currentState)
 {
     if (currentState == WorkState.PLAYING && conditionSatisfied && (then == null || then.IsFinished()))
     {
         return(WorkState.FINISHED);
     }
     return(base.CanChangeState(currentState));
 }