Example #1
0
        protected override Status DoTick(BTContext ctx)
        {
            var s = base.DoTick(ctx);

            ctx.unit.GetComponent <RVOController>().layer = s == Status.Running ? RVO.RVOLayer.Layer3 : RVO.RVOLayer.Layer2;
            return(s);
        }
Example #2
0
 protected override void OnTerminate(BTContext ctx)
 {
     if (lastStatus == Status.Running)
     {
         child.Terminate(ctx);
     }
 }
Example #3
0
 protected override void OnTerminate(BTContext ctx)
 {
     for (int i = 0; i <= childIndex; i++)
     {
         children[i].Terminate(ctx);
     }
     childIndex = -1;
 }
Example #4
0
        void Awake()
        {
            unit     = GetComponent <RTSUnit>();
            animator = GetComponent <Animator>();

            ctx = new BTContext {
                animator  = animator,
                transform = transform,
                unit      = unit
            };
        }
Example #5
0
 protected override void OnTerminate(BTContext ctx)
 {
     if (reserve && target.value != null)
     {
         if (target.value.reservedBy != ctx.unit)
         {
             throw new System.Exception();
         }
         target.value.reservedBy = null;
     }
     target.value = null;
 }
Example #6
0
 public Status Tick(BTContext ctx)
 {
     if (lastStatus == Status.Invalid)
     {
         OnInit(ctx);
     }
     lastStatus = DoTick(ctx);
     if (lastStatus == Status.Invalid)
     {
         throw new System.Exception();
     }
     return(lastStatus);
 }
Example #7
0
        protected override Status DoTick(BTContext ctx)
        {
            if (lastStatus == Status.Success)
            {
                return(Status.Success);
            }
            var s = child.Tick(ctx);

            if (s == Status.Success)
            {
                child.Terminate(ctx);
            }
            return(s);
        }
Example #8
0
        protected override Status DoTick(BTContext ctx)
        {
            var dest = destination.value;

            if ((Time.frameCount % 100) == 0)
            {
                ctx.unit.SetDestination(dest, MovementMode.Move);
            }
            if (VectorMath.SqrDistanceXZ(ctx.transform.position, dest) < 0.5f * 0.5f)
            {
                return(Status.Success);
            }
            else
            {
                return(Status.Running);
            }
        }
Example #9
0
        protected override Status DoTick(BTContext ctx)
        {
            if (target.value != null)
            {
                return(Status.Success);
            }

            target.value = FindClosest(ctx.transform.position);
            if (target.value != null)
            {
                if (reserve)
                {
                    target.value.reservedBy = ctx.unit;
                }
                return(Status.Success);
            }
            return(Status.Failure);
        }
Example #10
0
        protected override Status DoTick(BTContext ctx)
        {
            int i;

            for (i = 0; i < children.Length; i++)
            {
                var s = children[i].Tick(ctx);
                if (s != Status.Success)
                {
                    // Terminate all nodes that executed the last frame, but did not execute this frame
                    for (int j = i + 1; j <= childIndex; j++)
                    {
                        children[j].Terminate(ctx);
                    }
                    childIndex = i;
                    return(s);
                }
            }
            childIndex = i - 1;
            return(Status.Success);
        }
Example #11
0
 protected override Status DoTick(BTContext ctx)
 {
     time += Time.deltaTime;
     if (time > duration)
     {
         ctx.animator.SetBool("harvesting", false);
         if (ctx.animator.GetCurrentAnimatorStateInfo(0).IsName("RTSHarvesterHarvesting") || ctx.animator.GetCurrentAnimatorStateInfo(0).IsName("RTSHarvesterHarvestingExit"))
         {
             return(Status.Running);
         }
         else
         {
             ctx.unit.storedCrystals += 50;
             resource.value.value    -= 50;
             time = 0;
             //ctx.unit.locked = false;
             return(Status.Success);
         }
     }
     else
     {
         return(Status.Running);
     }
 }
Example #12
0
 protected override Status DoTick(BTContext ctx)
 {
     return(child.Tick(ctx));
 }
Example #13
0
 protected override void OnTerminate(BTContext ctx)
 {
     child.Terminate(ctx);
 }
Example #14
0
 protected abstract Status DoTick(BTContext ctx);
Example #15
0
 protected override void OnTerminate(BTContext ctx)
 {
     Debug.Log("Terminated harvesting");
     ctx.animator.SetBool("harvesting", false);
 }
Example #16
0
        protected override void OnInit(BTContext ctx)
        {
            ctx.animator.SetBool("harvesting", true);

            //ctx.unit.locked = true;
        }
Example #17
0
 protected override void OnInit(BTContext ctx)
 {
     ctx.unit.SetDestination(destination.value, MovementMode.Move);
 }
Example #18
0
 protected override void OnTerminate(BTContext ctx)
 {
     ctx.unit.GetComponent <RVOController>().layer = RVO.RVOLayer.Layer2;
     base.OnTerminate(ctx);
 }
Example #19
0
 protected virtual void OnTerminate(BTContext ctx)
 {
 }
Example #20
0
 protected virtual void OnInit(BTContext ctx)
 {
 }
Example #21
0
 protected override Status DoTick(BTContext ctx)
 {
     action(ctx);
     return(Status.Success);
 }
Example #22
0
 public void Terminate(BTContext ctx)
 {
     OnTerminate(ctx);
     lastStatus = Status.Invalid;
 }
Example #23
0
 protected override Status DoTick(BTContext ctx)
 {
     return(predicate(ctx) ? Status.Success : Status.Failure);
 }
Example #24
0
 protected override void OnInit(BTContext ctx)
 {
     childIndex = 0;
 }
Example #25
0
 protected override void OnInit(BTContext ctx)
 {
 }