Ejemplo n.º 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);
        }
    }
Ejemplo n.º 2
0
 public void OnRange()
 {
     follower.StopFollowing();
     meleeAttaker.Attack(target.GetTarget());
 }
Ejemplo n.º 3
0
 private void OnTooFar()
 {
     charge.ChargeAt(targetAi.GetTarget());
 }
Ejemplo n.º 4
0
 public void OnTooClose()
 {
     attacker.Attack(target.GetTarget());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 6
0
 public void OnTooClose()
 {
     keepDistance.KeepDistance(target.GetTarget());
 }