Beispiel #1
0
    public BehaviourJob CreateAndAddChildJob(IEnumerator co)
    {
        var j = new BehaviourJob(co, false);

        AddChildJob(j);
        return(j);
    }
Beispiel #2
0
 private IEnumerator DoWork()
 {
     while (IsRunning)
     {
         if (IsPaused)
         {
             yield return(null);
         }
         else
         {
             if (coroutine.MoveNext())
             {
                 yield return(coroutine.Current);
             }
             else
             {
                 if (null != childJobStack && childJobStack.Count > 0)
                 {
                     BehaviourJob childJob = childJobStack.Pop();
                     coroutine = childJob.coroutine;
                 }
                 else
                 {
                     isRunning = false;
                 }
             }
         }
     }
     OnComplete?.Invoke(isJobKilled);
     yield return(null);
 }
Beispiel #3
0
 public void AddChildJob(BehaviourJob j)
 {
     if (null == childJobStack)
     {
         childJobStack = new Stack <BehaviourJob>();
     }
     childJobStack.Push(j);
 }
Beispiel #4
0
 // Update is called once per frame
 void Update()
 {
     if (timer >= lifeTime)
     {
         if (!isFadeOut)
         {
             isFadeOut  = true;
             fadeOutJob = BehaviourJob.Make(IFadeOut(), true);
         }
     }
     else
     {
         timer += Time.deltaTime;
     }
 }
Beispiel #5
0
 public void RemoveChildJob(BehaviourJob childJob)
 {
     if (childJobStack.Contains(childJob))
     {
         var childStack     = new Stack <BehaviourJob>(childJobStack.Count - 1);
         var allCurChildren = childJobStack.ToArray();
         Array.Reverse(allCurChildren);
         for (int i = 0; i < allCurChildren.Length; i++)
         {
             var j = allCurChildren[i];
             if (j != childJob)
             {
                 childStack.Push(j);
             }
         }
         childJobStack = childStack;
     }
 }
Beispiel #6
0
 private void Start()
 {
     trapTrigger = GetComponent <Collider>();
     moveJob     = BehaviourJob.Make(IMoveTrack(), true);
 }