public class AiAttackWithinDistance { public float DistanceForAttack =

public class AiAttackWithinDistance {          public float DistanceForAttack = 30;    public float FrequencyForAttack = 0.25f;    public float DamageForAttack = 1;     private float attackCounter = 0;     void FindPlayerTarget()    {        if (DistanceForAttack != 30) {            if  (transform.position, DistanceForAttack.transform.position) > AttackRange) {                return 0;            }        }         foreach (var unit in RtsGamePlayerObjectsInteractive.Players) {            if (unit == player)                continue;             foreach (var unit in unit.ActiveUnits) {                if (Vector3.Distance (unit.transform.position, transform.position) < AttackRange) {                    DistanceForAttack = unit.GetComponent ();                    return;                }            }        }       DistanceForAttack = null;    }

Related Posts

© All Right Reserved