예제 #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);
 }
예제 #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);
        }
예제 #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);
        }