protected override void SetupStates() { SetAwareness(areaAwareness); State patrol = new Patrol(this, patrolData); State followTarget = new FollowTarget(this); Transition patrolToFollow = new HasTarget(followTarget, areaAwareness); Transition followToPatrol = new TargetIsFar(patrol, distanceToStopFollowing, areaAwareness); patrol.SetTransitions(patrolToFollow); followTarget.SetTransitions(followToPatrol); SetupFirstState(patrol); }
public AgentBehaviorTreeBuilder Condition(ConditionType type) { Condition condition = null; switch (type) { case ConditionType.IsDetecting_Agent: condition = new IsDetecting(agent, Tags.agent); break; case ConditionType.IsDetecting_Carcass: condition = new IsDetecting(agent, Tags.carcass); break; case ConditionType.IsDetecting_Plant: condition = new IsDetecting(agent, Tags.plant); break; case ConditionType.IsDetecting_Violence: condition = new IsDetecting(agent, Tags.violence); break; case ConditionType.IsHealth_AboveHalf: condition = new CompareFloats_DynamicToFixed(agent.stats.GetCurrentHealthToMaxRatio, Equality.GreaterThan, 0.5f); break; case ConditionType.IsStatus_Starving: condition = new CompareFloats_DynamicToFixed(agent.stats.GetCurrentHungerToMaxRatio, Equality.GreaterThanOrEqualTo, 1f); break; case ConditionType.HasTarget_Food: condition = new HasTarget(agent, TargetType.Food); break; } base.Condition(condition); return(this); }