Esempio n. 1
0
        public void Update()
        {
            List <int> lstNeedDelIndex = new List <int>();

            for (int i = 0; i < lstRoutine.Count; ++i)
            {
                RoutineInfo item = lstRoutine[i];
                if (null == item)
                {
                    continue;
                }

                bool bCallMoveNext = item.objYield == null || DealWithYieldInstruction(item);
                if (!bCallMoveNext)
                {
                    continue;
                }

                if (item.routine.MoveNext())
                {
                    SetRoutineInfo(ref item);
                }
                else
                {
                    lstNeedDelIndex.Add(i);
                }
            }

            for (int i = lstNeedDelIndex.Count - 1; i >= 0; i--)
            {
                lstRoutine.RemoveAt(lstNeedDelIndex[i]);
            }
        }
Esempio n. 2
0
 public void SetRoutineInfo(ref RoutineInfo objRoutineInfo)
 {
     if (objRoutineInfo.routine.Current is YieldInstruction)
     {
         objRoutineInfo.objYield     = objRoutineInfo.routine.Current as YieldInstruction;
         objRoutineInfo.objYieldInfo = new WaitForSecondsInfo(Time.timeSinceLevelLoad);
     }
 }
Esempio n. 3
0
 public bool DealWithYieldInstruction(RoutineInfo objRoutineInfo)
 {
     if (objRoutineInfo.objYield is WaitForSeconds waitForSec)
     {
         float objSpan = Time.timeSinceLevelLoad - ((WaitForSecondsInfo)objRoutineInfo.objYieldInfo).BeginTime;
         return(objSpan > waitForSec.Seconds);
     }
     return(true);
 }
Esempio n. 4
0
        public void StartCoroutine(IEnumerator routine)
        {
            if (null == routine)
            {
                return;
            }

            routine.MoveNext();
            var objRoutineInfo = new RoutineInfo {
                routine = routine
            };

            SetRoutineInfo(ref objRoutineInfo);
            lstRoutine.Add(objRoutineInfo);
        }