Exemple #1
0
 public bool IsInSightRange(Attackable a, int faction)
 {
     foreach (Attackable att in attackables)
     {
         if (att.Faction == faction && AttackableHelper.Distance(att, a) <= att.VisionRange)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        public List <Attackable> GetAllFriendlyUnitsInRange(Unit u, float range)
        {
            List <Attackable> friendly = new List <Attackable>();

            foreach (Attackable a in attackables)
            {
                if (a != u && a.Faction == u.Faction && AttackableHelper.Distance(u, a) <= range)
                {
                    friendly.Add(a);
                }
            }
            return(friendly);
        }
Exemple #3
0
        public Attackable GetNearestTarget(Attackable u, float range = float.MaxValue)
        {
            float      distance = float.MaxValue;
            Attackable closest  = null;

            foreach (Attackable a in attackables)
            {
                if (a == u || a.Faction == u.Faction)
                {
                    continue;
                }
                float d = AttackableHelper.Distance(u, a);
                if (d < range && d < distance)
                {
                    closest  = a;
                    distance = d;
                }
            }
            return(closest);
        }