Ejemplo n.º 1
0
        private void CommonUpdate()
        {
            currentTime += ReCoroutineManager.GetDeltaTime(this);

            if (!IsWaiting())
            {
                if (!e.MoveNext())
                {
                    isDone = true;
                }
                Wait(e.Current);

                if (e.Current.Equals(float.NaN))
                {
                    waitingCoroutine = replaceCoroutine;
                }
            }
            else
            {
                if (waitingCoroutine != null && waitingCoroutine.isDone)
                {
                    waitingCoroutine = null;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 等待异步操作
 /// </summary>
 /// <param name="operation"></param>
 /// <returns></returns>
 public static float WaitAsynOperation(AsyncOperation operation)
 {
     lock (lockObject)
     {
         replaceCoroutine = ReCoroutineManager.AddCoroutine(GetReplaceCoroutine(() => operation.isDone), CoroutineType.Update);
     }
     return(float.NaN);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 等待www返回
 /// </summary>
 /// <param name="www"></param>
 /// <returns></returns>
 public static float WaitWWW(WWW www)
 {
     lock (lockObject)
     {
         replaceCoroutine = ReCoroutineManager.AddCoroutine(GetReplaceCoroutine(() => www.isDone), CoroutineType.Update);
     }
     return(float.NaN);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 等待线程操作
        /// </summary>
        /// <param name="act"></param>
        /// <returns></returns>
        public static float WaitThreadOperation(Action act)
        {
            Thread thread = new Thread(new ThreadStart(act));

            thread.Start();
            lock (lockObject)
                replaceCoroutine = ReCoroutineManager.AddCoroutine(GetReplaceCoroutine(() => !thread.IsAlive), CoroutineType.Update);
            return(float.NaN);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 等待所有其他携程
 /// </summary>
 /// <param name="coroutines"></param>
 /// <returns></returns>
 public static float WaitForAllCoroutines(params ReCoroutine[] coroutines)
 {
     lock (lockObject)
         replaceCoroutine = ReCoroutineManager.AddCoroutine(
             GetReplaceCoroutine(() => {
             for (int i = 0; i < coroutines.Length; i++)
             {
                 if (!coroutines[i].isDone)
                 {
                     return(false);
                 }
             }
             return(true);
         }),
             CoroutineType.Update);
     return(float.NaN);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 等待知道
 /// </summary>
 /// <param name="condition"></param>
 /// <returns></returns>
 public static float WaitUntil(Func <bool> condition)
 {
     lock (lockObject)
         replaceCoroutine = ReCoroutineManager.AddCoroutine(GetReplaceCoroutine(condition), CoroutineType.Update);
     return(float.NaN);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 等待其他协程
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public static float Wait(IEnumerator <float> e)
 {
     lock (lockObject)
         replaceCoroutine = ReCoroutineManager.AddCoroutine(e);
     return(float.NaN);
 }
Ejemplo n.º 8
0
 public void Start()
 {
     running    = true;
     isFinished = false;
     ReCoroutineManager.AddCoroutine(DoTask());
 }