Esempio n. 1
0
        public static ServerSideObject GetNearMinionsHeroes(ServerSideObject tower, float attackRange)
        {
            ServerSideObject ret         = null;
            float            mindistance = float.MaxValue;

            foreach (KeyValuePair <ushort, Minion> minion in minions)
            {
                if (!minion.Value.IsDead() && minion.Value.GetFaction() != tower.GetFaction())
                {
                    float distance = ServerMath.Distance(tower, minion.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = minion.Value;
                        mindistance = distance;
                    }
                }
            }

            if (ret != null)
            {
                return(ret);
            }

            foreach (KeyValuePair <ushort, Hero> hero in heroes)
            {
                if (!hero.Value.IsDead() && hero.Value.GetFaction() != tower.GetFaction())
                {
                    float distance = ServerMath.Distance(tower, hero.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = hero.Value;
                        mindistance = distance;
                    }
                }
            }

            return(ret);
        }
Esempio n. 2
0
        public static ServerSideObject GetNearMinionsCoresTowersHeroes(ServerSideObject myminion, float attackRange)
        {
            ServerSideObject ret         = null;
            float            mindistance = float.MaxValue;

            foreach (KeyValuePair <ushort, Minion> minion in minions)
            {
                if (!minion.Value.IsDead() && minion.Value.GetFaction() != myminion.GetFaction())
                {
                    float distance = ServerMath.Distance(myminion, minion.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = minion.Value;
                        mindistance = distance;
                    }
                }
            }

            if (ret != null)
            {
                return(ret);
            }

            foreach (KeyValuePair <ushort, Core> core in cores)
            {
                if (!core.Value.IsDead() && core.Value.GetFaction() != myminion.GetFaction())
                {
                    float distance = ServerMath.Distance(myminion, core.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = core.Value;
                        mindistance = distance;
                    }
                }
            }

            if (ret != null)
            {
                return(ret);
            }

            foreach (KeyValuePair <ushort, Tower> tower in towers)
            {
                if (!tower.Value.IsDead() && tower.Value.GetFaction() != myminion.GetFaction())
                {
                    float distance = ServerMath.Distance(myminion, tower.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = tower.Value;
                        mindistance = distance;
                    }
                }
            }

            if (ret != null)
            {
                return(ret);
            }

            foreach (KeyValuePair <ushort, Hero> hero in heroes)
            {
                if (!hero.Value.IsDead() && hero.Value.GetFaction() != myminion.GetFaction())
                {
                    float distance = ServerMath.Distance(myminion, hero.Value);
                    if (distance <= attackRange && distance < mindistance)
                    {
                        ret         = hero.Value;
                        mindistance = distance;
                    }
                }
            }

            return(ret);
        }