예제 #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);
        }
예제 #2
0
 protected override void OnTerminate(BTContext ctx)
 {
     if (lastStatus == Status.Running)
     {
         child.Terminate(ctx);
     }
 }
예제 #3
0
 protected override void OnTerminate(BTContext ctx)
 {
     for (int i = 0; i <= childIndex; i++)
     {
         children[i].Terminate(ctx);
     }
     childIndex = -1;
 }
예제 #4
0
        void Awake()
        {
            unit     = GetComponent <RTSUnit>();
            animator = GetComponent <Animator>();

            ctx = new BTContext {
                animator  = animator,
                transform = transform,
                unit      = unit
            };
        }
예제 #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;
 }
예제 #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);
 }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
     }
 }
예제 #12
0
 protected override Status DoTick(BTContext ctx)
 {
     return(child.Tick(ctx));
 }
예제 #13
0
 protected override void OnTerminate(BTContext ctx)
 {
     child.Terminate(ctx);
 }
예제 #14
0
 protected abstract Status DoTick(BTContext ctx);
예제 #15
0
 protected override void OnTerminate(BTContext ctx)
 {
     Debug.Log("Terminated harvesting");
     ctx.animator.SetBool("harvesting", false);
 }
예제 #16
0
        protected override void OnInit(BTContext ctx)
        {
            ctx.animator.SetBool("harvesting", true);

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