private void Update() { float distance = Vector2.Distance(transform.position, target.GetTarget().position); Debug.DrawLine(transform.position, target.GetTarget().position, Color.magenta); //Debug.Log(string.Format("Distance: {0} Max: {1} Min:{2}", distance, maxRange, minRange)); if (distance > maxRange) { CallCallbacks(tooFarCallbacks); if (maxRange == float.NegativeInfinity) { CallCallbacks(inRangeCallbacks); } } else if (distance < minRange) { CallCallbacks(tooCloseCallbacks); if (minRange == float.PositiveInfinity) { CallCallbacks(inRangeCallbacks); } } else { CallCallbacks(inRangeCallbacks); } }
public void OnRange() { follower.StopFollowing(); meleeAttaker.Attack(target.GetTarget()); }
private void OnTooFar() { charge.ChargeAt(targetAi.GetTarget()); }
public void OnTooClose() { attacker.Attack(target.GetTarget()); }
/// <summary> /// Makes this agent walk to the target /// </summary> public void Follow() { Walker.Direction dir = (target.GetTarget().position - transform.position).x > 0 ? Walker.Direction.RIGHT : Walker.Direction.LEFT; walker.Walk(dir); }
public void OnTooClose() { keepDistance.KeepDistance(target.GetTarget()); }