public override void FixedUpdate(Sheep owner) { base.FixedUpdate(owner); owner.Hunger -= 2; if (owner.Hunger > 2) { return; } if (owner.GetSteering.NearEntities.Count == 0) { owner.GetFSM.ChangeState(WanderingSheepState.GetInstance()); return; } MovingEntity entity = owner.GetSteering.GetNearestEntity(); float dist = Vector3.Distance(owner.transform.position, entity.transform.position); if (dist > 2 || owner.Hunger < Random.Range(10, 20)) { owner.GetFSM.ChangeState(GroupSheepState.GetInstance()); } }
public override void FixedUpdate(Sheep owner) { base.FixedUpdate(owner); ++owner.Hunger; if (Vector3.Distance(owner.Position, owner.GetSteering.ThreatTrans.position) < owner.GetSteering.settings.panicDist) { owner.GetFSM.ChangeState(FleeingSheepState.GetInstance()); } else if (owner.Hunger > owner.HungerDissatisfier) { owner.GetFSM.ChangeState(WanderingSheepState.GetInstance()); } }
public override void FixedUpdate(Sheep owner) { base.FixedUpdate(owner); MovingEntity entity = owner.GetSteering.GetNearestEntity(); if (entity == null) { owner.GetFSM.ChangeState(WanderingSheepState.GetInstance()); return; } float dist = Vector3.Distance(owner.transform.position, entity.transform.position); if (dist < 1) { owner.GetFSM.ChangeState(GrazingSheepState.GetInstance()); } }
private void Start() { stateMachine.SetCurrentState(WanderingSheepState.GetInstance()); stateMachine.SetGlobalState(GlobalSheepState.GetInstance()); }