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); }
protected override void OnTerminate(BTContext ctx) { if (lastStatus == Status.Running) { child.Terminate(ctx); } }
protected override void OnTerminate(BTContext ctx) { for (int i = 0; i <= childIndex; i++) { children[i].Terminate(ctx); } childIndex = -1; }
void Awake() { unit = GetComponent <RTSUnit>(); animator = GetComponent <Animator>(); ctx = new BTContext { animator = animator, transform = transform, unit = unit }; }
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; }
public Status Tick(BTContext ctx) { if (lastStatus == Status.Invalid) { OnInit(ctx); } lastStatus = DoTick(ctx); if (lastStatus == Status.Invalid) { throw new System.Exception(); } return(lastStatus); }
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); }
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); } }
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); }
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); }
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); } }
protected override Status DoTick(BTContext ctx) { return(child.Tick(ctx)); }
protected override void OnTerminate(BTContext ctx) { child.Terminate(ctx); }
protected abstract Status DoTick(BTContext ctx);
protected override void OnTerminate(BTContext ctx) { Debug.Log("Terminated harvesting"); ctx.animator.SetBool("harvesting", false); }
protected override void OnInit(BTContext ctx) { ctx.animator.SetBool("harvesting", true); //ctx.unit.locked = true; }
protected override void OnInit(BTContext ctx) { ctx.unit.SetDestination(destination.value, MovementMode.Move); }
protected override void OnTerminate(BTContext ctx) { ctx.unit.GetComponent <RVOController>().layer = RVO.RVOLayer.Layer2; base.OnTerminate(ctx); }
protected virtual void OnTerminate(BTContext ctx) { }
protected virtual void OnInit(BTContext ctx) { }
protected override Status DoTick(BTContext ctx) { action(ctx); return(Status.Success); }
public void Terminate(BTContext ctx) { OnTerminate(ctx); lastStatus = Status.Invalid; }
protected override Status DoTick(BTContext ctx) { return(predicate(ctx) ? Status.Success : Status.Failure); }
protected override void OnInit(BTContext ctx) { childIndex = 0; }
protected override void OnInit(BTContext ctx) { }