Exemplo n.º 1
0
        /// <summary>
        /// Returns the point where, when casted, the circular spell with hit the maximum amount of minions.
        /// </summary>
        /// <param name="minionPositions">The minion positions.</param>
        /// <param name="width">The width.</param>
        /// <param name="range">The range.</param>
        /// <param name="useMECMax">The use mec maximum.</param>
        /// <returns>FarmLocation.</returns>
        public static FarmLocation GetBestCircularFarmLocation(List <Vector2> minionPositions,
                                                               float width,
                                                               float range,
                                                               // ReSharper disable once InconsistentNaming
                                                               int useMECMax = 9)
        {
            var result      = new Vector2();
            var minionCount = 0;
            var startPos    = ObjectManager.Player.ServerPosition.To2D();

            range = range * range;

            if (minionPositions.Count == 0)
            {
                return(new FarmLocation(result, minionCount));
            }

            /* Use MEC to get the best positions only when there are less than 9 positions because it causes lag with more. */
            if (minionPositions.Count <= useMECMax)
            {
                var subGroups = GetCombinations(minionPositions);
                foreach (var subGroup in subGroups)
                {
                    if (subGroup.Count > 0)
                    {
                        var circle = MEC.GetMec(subGroup);

                        if (circle.Radius <= width && circle.Center.Distance(startPos, true) <= range)
                        {
                            minionCount = subGroup.Count;
                            return(new FarmLocation(circle.Center, minionCount));
                        }
                    }
                }
            }
            else
            {
                foreach (var pos in minionPositions)
                {
                    if (pos.Distance(startPos, true) <= range)
                    {
                        var count = minionPositions.Count(pos2 => pos.Distance(pos2, true) <= width * width);

                        if (count >= minionCount)
                        {
                            result      = pos;
                            minionCount = count;
                        }
                    }
                }
            }

            return(new FarmLocation(result, minionCount));
        }
Exemplo n.º 2
0
        public static OptimizedLocation GetOptimizedCircleLocation(List <Vector2> champPositions,
                                                                   float width,
                                                                   float range,
                                                                   // ReSharper disable once InconsistentNaming
                                                                   int useMECMax = 9)
        {
            var result    = new Vector2();
            var champsHit = 0;
            var startPos  = ObjectManager.Player.ServerPosition.To2D();

            range = range * range;

            if (champPositions.Count == 0)
            {
                return(new CastManager.OptimizedLocation(result, champsHit));
            }

            if (champPositions.Count <= useMECMax)
            {
                var subGroups = GetCombinations(champPositions);
                foreach (var subGroup in subGroups)
                {
                    if (subGroup.Count > 0)
                    {
                        var circle = MEC.GetMec(subGroup);

                        if (circle.Radius <= width && circle.Center.Distance(startPos, true) <= range)
                        {
                            champsHit = subGroup.Count;
                            return(new CastManager.OptimizedLocation(circle.Center, champsHit));
                        }
                    }
                }
            }
            else
            {
                foreach (var pos in champPositions)
                {
                    if (pos.Distance(startPos, true) <= range)
                    {
                        var count = champPositions.Count(pos2 => pos.Distance(pos2, true) <= width * width);

                        if (count >= champsHit)
                        {
                            result    = pos;
                            champsHit = count;
                        }
                    }
                }
            }

            return(new OptimizedLocation(result, champsHit));
        }