public Unit GetRandomTarget(Vector2 Distance, int Range)
        {
            UnitList units = GetTargets(Distance, Range);

            if (units.Count == 0)
            {
                return(null);
            }
            return(units[mRand.Next(units.Count)]);
        }
        public virtual UnitList GetTargets(Vector2 Distance, int Range)
        {
            UnitList units = new UnitList();

            for (int i = 0; i < Count; i++)
            {
                units.AddRange(this[i].GetTargets(Distance, Range));
            }
            return(units);
        }
        public virtual UnitList GetUnits()
        {
            UnitList list = new UnitList();

            for (int i = 0; i < Count; i++)
            {
                list.AddRange(this[i].Units);
            }
            return(list);
        }
Exemple #4
0
        public virtual UnitList GetTargets(Vector2 Distance, int Range)
        {
            UnitList units = new UnitList();

            for (int i = 0; i < mUnits.Count; i++)
            {
                if (mUnits[i].Dead || mUnits[i].GetDistance(Distance) > Range)
                {
                    continue;
                }
                units.Add(mUnits[i]);
            }

            return(units);
        }
Exemple #5
0
        public virtual Unit GetRandomTarget(Vector2 Distance, int Range)
        {
            UnitList randUnits = new UnitList();

            for (int i = 0; i < mUnits.Count; i++)
            {
                if (mUnits[i].Dead || mUnits[i].GetDistance(Distance) > Range)
                {
                    continue;
                }
                randUnits.Add(mUnits[i]);
            }

            if (randUnits.Count == 0)
            {
                return(null);
            }
            return(randUnits[mRand.Next(randUnits.Count)]);
        }
        public Unit GetClosestTarget(Vector2 Distance, int Range)
        {
            Unit     u;
            UnitList units = new UnitList();

            for (int i = 0; i < Count; i++)
            {
                if ((u = this[i].GetClosestTarget(Distance, Range)) != null)
                {
                    units.Add(u);
                }
            }

            if (units.Count == 0)
            {
                return(null);
            }

            float closestSoFar = Range;
            float currentRange = units[0].GetDistance(Distance);

            u = units[0];

            for (int i = 0; i < units.Count; i++)
            {
                if (currentRange >= closestSoFar)
                {
                    continue;
                }

                closestSoFar = currentRange;
                u            = units[i];
            }

            return(u);
        }