public void RunRocket() { var targetIsValid = _targetKnower.CurrentTarget != null && _targetKnower.CurrentTarget.Transform.IsValid(); if (targetIsValid) { if (_tank == null || _tank.HasFuel()) { //Debug.Log(name + " is flying at " + _targetKnower.CurrentTarget.Transform); _pilot.Fly(_targetKnower.CurrentTarget); } if (_pilot.StartDelay <= 0) { _detonator.AutoDetonate(_targetKnower.CurrentTarget); } } //else //{ // Debug.Log(name + " has no target"); //} if (_tank != null && !_tank.HasFuel()) { _targetKnower.Deactivate(); } }
public void RunRocket() { var allTargets = _targetDetector.DetectTargets(); var bestTarget = _targetPicker.FilterTargets(allTargets).OrderByDescending(t => t.Score).FirstOrDefault(); if (_knower != null) { _knower.CurrentTarget = bestTarget; } //Debug.Log(name + " is flying at " + bestTarget.TargetTransform); _pilot.Fly(bestTarget); if (_pilot.StartDelay <= 0) { _detonator.AutoDetonate(bestTarget); } //Disabled detonation when out of fuel. //if(_engineControl.RemainingFuel < DetonateWithLessThanXRemainingFuel) //{ // _detonator.DetonateNow(); //} }