Exemplo n.º 1
0
 private bool IsNextRepeat()
 {
     if (_currentIndex - 1 >= 0)
     {
         Cooperator nextCooperator = _cooperators[_currentIndex - 1];
         return(nextCooperator is CooperatorRepeat);
     }
     return(false);
 }
Exemplo n.º 2
0
 public CooperatorRepeat(Cooperator parent, int repeatCount)
     : base(parent)
 {
     _repeatCount = repeatCount;
     _predicate   = () =>
     {
         return(_repeatCurrentCount++ < _repeatCount);
     };
 }
Exemplo n.º 3
0
        public static Cooperator YieldCoroutine(this Cooperator cooperator, IEnumerator appendCoroutine)
        {
            Cooperator appendCooperator = appendCoroutine as Cooperator;

            if (appendCooperator != null)
            {
                cooperator.Yield(appendCooperator.New());
            }

            return(cooperator.Yield(appendCoroutine));
        }
Exemplo n.º 4
0
        void IEnumerator.Reset()
        {
            _cooperators = new List <Cooperator>();

            Cooperator curr = this;

            while (curr != null)
            {
                _cooperators.Add(curr);
                curr = curr.Parent;
            }

            _currentIndex = _cooperators.Count;

            Reset();
        }
Exemplo n.º 5
0
        bool IEnumerator.MoveNext()
        {
            if (_currentIndex < 0)
            {
                (this as IEnumerator).Reset();
            }

            bool isRepeatingRoutine = false;

            while (0 <= --_currentIndex)
            {
                if (isRepeatingRoutine == false && IsNextRepeat())
                {
                    continue;
                }

                Cooperator currCooperator = _cooperators[_currentIndex];

                object prevInstruction = _current;
                object resultInstruction;
                if (currCooperator.Instruct(prevInstruction, out resultInstruction))
                {
                    _current = resultInstruction;
                    return(true);
                }
                else
                {
                    if (isRepeatingRoutine)
                    {
                        return(true);
                    }

                    if (currCooperator.IsRepeat())
                    {
                        isRepeatingRoutine = true;
                        _currentIndex     += 2;
                    }
                }
            }
            return(false);
        }
Exemplo n.º 6
0
 public static CooperatorFunc <TPrevInstruction, TCurrInstruction> YieldAction <TPrevInstruction, TCurrInstruction>(this Cooperator <TPrevInstruction> cooperator, Func <TPrevInstruction, TCurrInstruction> func)
 {
     return(new CooperatorFunc <TPrevInstruction, TCurrInstruction>(cooperator, func));
 }
Exemplo n.º 7
0
 public CooperatorFunc(Cooperator parent, Func <TCurrInstruction> coroutine)
     : base(parent, default(TCurrInstruction))
 {
     Coroutine = coroutine;
 }
Exemplo n.º 8
0
 public static Cooperator New(this Cooperator cooperator)
 {
     return(cooperator.Clone());
 }
Exemplo n.º 9
0
 public static Cooperator <WaitForSeconds> YieldWaitForSeconds(this Cooperator cooperator, float seconds)
 {
     return(cooperator.Yield(new WaitForSeconds(seconds)));
 }
Exemplo n.º 10
0
 public static Cooperator <WaitForFixedUpdate> YieldWaitForFixedUpdate(this Cooperator cooperator)
 {
     return(cooperator.Yield(new WaitForFixedUpdate()));
 }
Exemplo n.º 11
0
 public static Cooperator <WaitForEndOfFrame> YieldWaitForEndOfFrame(this Cooperator cooperator)
 {
     return(cooperator.Yield(new WaitForEndOfFrame()));
 }
Exemplo n.º 12
0
 public static Cooperator <TCurrInstruction> Yield <TCurrInstruction>(this Cooperator cooperator, TCurrInstruction instruction)
 {
     return(new Cooperator <TCurrInstruction>(cooperator, instruction));
 }
Exemplo n.º 13
0
 public static Cooperator <WWW> YieldWWW(this Cooperator cooperator, WWW www)
 {
     return(cooperator.Yield(www));
 }
Exemplo n.º 14
0
 public static Cooperator YieldWaitForNextFrame(this Cooperator cooperator)
 {
     return(cooperator.Yield((object)null));
 }
Exemplo n.º 15
0
 public static CooperatorRepeat Repeat <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator, Func <bool> predicate)
 {
     return(new CooperatorRepeat(cooperator, predicate));
 }
Exemplo n.º 16
0
 public static CooperatorRepeat Repeat <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator, int repeatCount)
 {
     return(new CooperatorRepeat(cooperator, repeatCount));
 }
Exemplo n.º 17
0
 public static Cooperator <WaitForSecondsRealtime> YieldWaitForSecondsRealtime(this Cooperator cooperator, float seconds)
 {
     return(cooperator.YieldAction(() => new WaitForSecondsRealtime(seconds)));
 }
Exemplo n.º 18
0
 public static Cooperator <TCurrInstruction> New <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator)
 {
     return(cooperator.Clone() as Cooperator <TCurrInstruction>);
 }
Exemplo n.º 19
0
 public static Cooperator <WaitWhile> YieldWaitWhile(this Cooperator cooperator, Func <bool> predicate)
 {
     return(cooperator.YieldAction(() => new WaitWhile(predicate)));
 }
Exemplo n.º 20
0
 public static Cooperator <AsyncOperation> YieldAsyncOperation(this Cooperator cooperator, AsyncOperation asyncOperation)
 {
     return(cooperator.Yield(asyncOperation));
 }
Exemplo n.º 21
0
 public static Cooperator <TCustomYieldInstruction> YieldCustom <TCustomYieldInstruction>(this Cooperator cooperator, TCustomYieldInstruction customYieldInstruction)
     where TCustomYieldInstruction : CustomYieldInstruction
 {
     return(cooperator.Yield(customYieldInstruction));
 }
Exemplo n.º 22
0
 public Cooperator(Cooperator parent)
 {
     Parent = parent;
 }
Exemplo n.º 23
0
 public static CooperatorAction Action(this Cooperator cooperator, Action action)
 {
     return(new CooperatorAction(cooperator, action));
 }
Exemplo n.º 24
0
 public CooperatorRepeat(Cooperator parent, Func <bool> predicate)
     : base(parent)
 {
     _predicate = predicate;
 }
Exemplo n.º 25
0
 public static CooperatorAction <TPrevInstruction> Action <TPrevInstruction>(this Cooperator <TPrevInstruction> cooperator, Action <TPrevInstruction> action)
 {
     return(new CooperatorAction <TPrevInstruction>(cooperator, action));
 }
Exemplo n.º 26
0
 public CooperatorAction(Cooperator parent, Action coroutine)
     : base(parent)
 {
     Coroutine = coroutine;
 }
Exemplo n.º 27
0
 public static Cooperator YieldCoroutine(this Cooperator cooperator, Coroutine appendCoroutine)
 {
     return(cooperator.Yield(appendCoroutine));
 }