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() { List <Enemy> tooCloseEnemies = _homer.GetTooCloseEnemies(); if (tooCloseEnemies.Count == 0) { return(_wander); } _steeringController.SetBehaviours( tooCloseEnemies.ConvertAll <SteeringBehaviour>( (e) => new SteerFromTarget(this.gameObject.transform, e.transform) ) ); _steeringController.AddBehaviours(new SteerAvoidBuildings(this.transform)); _steeringController.Steer(); return(this); }