public override FiniteState CheckState() { if (_homer.EnemyTooClose()) { return(_escape); } List <Homer> homersInFlockingRange = _homer.GetHomersCloseEnoughToFlock().FindAll(h => h.capturer == null); if (homersInFlockingRange.Count == 0) { return(_wander); } _steeringController.SetBehaviours( homersInFlockingRange.ConvertAll <SteeringBehaviour>( (h) => new SteerToTarget(this.gameObject.transform, h.transform) ) ); _steeringController.AddBehaviours( _homer.GetTooCloseHomers().ConvertAll <SteeringBehaviour>( (h) => new SteerFromTarget(this.gameObject.transform, h.transform) ) ); _steeringController.AddBehaviours(new SteerAvoidBuildings(this.transform)); _steeringController.Steer(); return(this); }
public override FiniteState CheckState() { if (_homer.EnemyTooClose()) { return(_escape); } if (_homer.HomerCloseEnoughToFlock()) { return(_flock); } _steeringController.SetBehaviours( new List <SteeringBehaviour>() { new SteerAvoidBuildings(this.transform), new SteerWanderXZ(this.gameObject.transform) } ); _steeringController.Steer(); return(this); }