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 static GroupSheepState GetInstance() { if (instance == null) { instance = new GroupSheepState(); } return(instance); }
public override void FixedUpdate(Sheep owner) { base.FixedUpdate(owner); MovingEntity entity = owner.GetSteering.GetNearestEntity(); if (entity == null) { return; } float dist = Vector3.Distance(owner.transform.position, entity.transform.position); if (dist > 2) { owner.GetFSM.ChangeState(GroupSheepState.GetInstance()); } }