Beispiel #1
0
 public void MoveNext()
 {
     bool final = enumer.MoveNext();
     if (final)
     {
         if (enumer.Current is Coroutine)
         {
             var co = enumer.Current as Coroutine;
             LinkedListNode<Action> node = new LinkedListNode<Action>(co.MoveNext);
             stack.AddLast(node);
             co.MoveNext();
         }
         if (enumer.Current is IEnumerator)
         {
             var co = new Coroutine(enumer.Current as IEnumerator);
             LinkedListNode<Action> node = new LinkedListNode<Action>(co.MoveNext);
             stack.AddLast(node);
             co.MoveNext();
         }
     }
     else
     {
         stack.Last.Value -= MoveNext;
         if (stack.Last.Value == null)
         {
             stack.RemoveLast();
             Run();
         }
     }
 }
Beispiel #2
0
 public static Coroutine Start(IEnumerator enumer)
 {
     var co = new Coroutine(enumer);
     if (stack.Count <= 0)
     {
         var node = new LinkedListNode<Action>(co.MoveNext);
         stack.AddLast(node);
     }
     else
     {
         stack.Last.Value += co.MoveNext;
     }
     return co;
 }