Пример #1
0
    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);
        }
    }
Пример #2
0
 public void OnRange()
 {
     follower.StopFollowing();
     meleeAttaker.Attack(target.GetTarget());
 }
Пример #3
0
 private void OnTooFar()
 {
     charge.ChargeAt(targetAi.GetTarget());
 }
Пример #4
0
 public void OnTooClose()
 {
     attacker.Attack(target.GetTarget());
 }
Пример #5
0
 /// <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);
 }
Пример #6
0
 public void OnTooClose()
 {
     keepDistance.KeepDistance(target.GetTarget());
 }