Пример #1
0
        /// <summary>
        /// Gets Aoe Prediction result
        /// </summary>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns>
        public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result  = new Prediction.AoeResult();
            var enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range);

            foreach (var enemy in enemies)
            {
                Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom);
                if (prediction.HitChance > HitChance.Medium)
                {
                    float multp = (result.CastPosition.Distance(from) / 875.0f);

                    var spellHitBox = new SPredictionMash.Geometry.Polygon(
                        ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 200 * multp),
                        ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 320 * multp));

                    var collidedEnemies = GameObjects.EnemyHeroes.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), ClipperWrapper.MakePaths(spellHitBox)));
                    int collisionCount  = collidedEnemies.Count();
                    if (collisionCount > result.HitCount)
                    {
                        result = prediction.ToAoeResult(collisionCount, new Collision.Result(collidedEnemies.ToList <AIBaseClient>(), Collision.Flags.EnemyChampions));
                    }
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Gets Aoe Prediction result
        /// </summary>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns>
        public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result  = new Prediction.AoeResult();
            var enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range);

            if (enemies.Count() > 0)
            {
                Vector2 posSummary = Vector2.Zero;
                enemies.AsParallel().ForAll(p => posSummary += Prediction.GetFastUnitPosition(p, delay, missileSpeed, from));
                Vector2 center  = posSummary / enemies.Count();
                float   flyTime = 0;
                if (missileSpeed != 0)
                {
                    flyTime = from.Distance(center) / missileSpeed;
                }

                posSummary = Vector2.Zero;
                List <Tuple <Prediction.Result, float> > predictionResults = new List <Tuple <Prediction.Result, float> >();

                foreach (var enemy in enemies)
                {
                    Prediction.Result prediction = GetPrediction(enemy, width, delay + flyTime, 0, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom);
                    if (prediction.HitChance > HitChance.Medium)
                    {
                        posSummary += prediction.UnitPosition;
                        predictionResults.Add(new Tuple <Prediction.Result, float>(prediction, enemy.BoundingRadius));
                    }
                }

                if (predictionResults.Count > 0)
                {
                    center = posSummary / predictionResults.Count;
                    result.CastPosition = center;
                    foreach (Tuple <Prediction.Result, float> res in predictionResults)
                    {
                        if (center.CircleCircleIntersection(res.Item1.UnitPosition, width, res.Item2).Length > 1)
                        {
                            result.HitCount++;
                        }
                    }
                }

                predictionResults.Clear();
                GC.Collect(GC.GetGeneration(predictionResults));
            }

            return(result);
        }
        /// <summary>
        /// Gets Aoe Prediction result
        /// </summary>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns>
        public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result  = new Prediction.AoeResult();
            var enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range);

            foreach (var enemy in enemies)
            {
                Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom);
                if (prediction.HitChance > HitChance.Medium)
                {
                    Vector2 to              = from + (prediction.CastPosition - from).Normalized() * range;
                    var     spellHitBox     = ClipperWrapper.DefineSector(from, to, width, range);
                    var     collidedEnemies = GameObjects.EnemyHeroes.AsParallel().Where(p => !ClipperWrapper.IsOutside(spellHitBox, Prediction.GetFastUnitPosition(p, delay, missileSpeed, from)));
                    int     collisionCount  = collidedEnemies.Count();
                    if (collisionCount > result.HitCount)
                    {
                        result = prediction.ToAoeResult(collisionCount, new Collision.Result(collidedEnemies.ToList <AIBaseClient>(), Collision.Flags.EnemyChampions));
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Gets Aoe Prediction result
        /// </summary>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns>
        public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom)
        {
            var result  = new Prediction.AoeResult();
            var enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range);

            foreach (var enemy in enemies)
            {
                Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom);
                if (prediction.HitChance > HitChance.Medium)
                {
                    Vector2          to        = from + (prediction.CastPosition - from).Normalized() * range;
                    Collision.Result colResult = Collision.GetCollisions(from, to, range, width, delay, missileSpeed, false);
                    if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions))
                    {
                        int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.Type == GameObjectType.AIHeroClient && p.IsValid);
                        if (collisionCount > result.HitCount)
                        {
                            result = prediction.ToAoeResult(collisionCount, colResult);
                        }
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Gets prediction result
        /// </summary>
        /// <param name="target">Target</param>
        /// <param name="width">Vector width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="vectorSpeed">Vector speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="vectorLenght">Vector lenght</param>
        /// <param name="path">Waypoints of target</param>
        /// <param name="avgt">Average reaction time (in ms)</param>
        /// <param name="movt">Passed time from last movement change (in ms)</param>
        /// <param name="avgp">Average Path Lenght</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.Vector.Result"/></returns>
        public static Result GetPrediction(AIBaseClient target, float width, float delay, float vectorSpeed, float range, float vectorLenght, List <Vector2> path, float avgt, float movt, float avgp, Vector2 rangeCheckFrom)
        {
            Prediction.AssertInitializationMode();

            Result result = new Result();

            //auto aoe hit (2 hits with using one target as from position)
            if (target.Type == GameObjectType.AIHeroClient && target.IsValid)                                                                                                                                                                                                                                                                                                                               //do these calcs if champion kappa
            {
                if (ObjectManager.Player.CountEnemyHeroesInRange(range) > 0 && ObjectManager.Player.CountEnemyHeroesInRange(range + vectorLenght) > 1)                                                                                                                                                                                                                                                      //if there is at least 1 enemy in range && at least 2 enemy which laser can hit
                {
                    Vector2 predPos1 = Prediction.GetFastUnitPosition(target, delay);                                                                                                                                                                                                                                                                                                                       //get target unit position after delay
                    foreach (var enemy in GameObjects.EnemyHeroes)                                                                                                                                                                                                                                                                                                                                          //loop all enemies
                    {
                        if (enemy.NetworkId != target.NetworkId && enemy.Distance(rangeCheckFrom) < range + vectorLenght)                                                                                                                                                                                                                                                                                   //if enemy is not given target and enemy is hitable by laser
                        {
                            Vector2 predPos2 = Prediction.GetFastUnitPosition(enemy, delay);                                                                                                                                                                                                                                                                                                                //get enemy unit position after delay
                            if (predPos1.Distance(rangeCheckFrom) < range)                                                                                                                                                                                                                                                                                                                                  //if target is in range
                            {
                                Prediction.Result predRes = LinePrediction.GetPrediction(enemy, width, delay, vectorSpeed, vectorLenght, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), 360, predPos1 - (predPos1 - rangeCheckFrom).Normalized().Perpendicular() * 30, predPos1 - (predPos1 - rangeCheckFrom).Normalized().Perpendicular() * 30); //get enemy prediciton with from = target's position (a bit backward)
                                if (predRes.HitChance >= HitChance.Low)
                                {
                                    return(predRes.AsVectorResult(predPos1 - (predPos1 - rangeCheckFrom).Normalized().Perpendicular() * 30));
                                }
                            }
                            else if (predPos2.Distance(rangeCheckFrom) < range)                                                                                                                                                                                                                                                    //if enemy is in range
                            {
                                Prediction.Result predRes = LinePrediction.GetPrediction(target, width, delay, vectorSpeed, vectorLenght, false, path, avgt, movt, avgp, 360, predPos2 - (predPos2 - rangeCheckFrom).Normalized().Perpendicular() * 30, predPos2 - (predPos2 - rangeCheckFrom).Normalized().Perpendicular() * 30); //get target prediction with from = enemy's position (a bit backward)
                                if (predRes.HitChance >= HitChance.Low)
                                {
                                    return(predRes.AsVectorResult(predPos2 - (predPos2 - rangeCheckFrom).Normalized().Perpendicular() * 30));
                                }
                            }
                        }
                    }
                }
            }

            Vector2 immobileFrom = rangeCheckFrom + (target.PreviousPosition.ToVector2() - rangeCheckFrom).Normalized() * range;

            if (path.Count <= 1) //if target is not moving, easy to hit
            {
                result.HitChance          = HitChance.VeryHigh;
                result.CastSourcePosition = immobileFrom;
                result.CastTargetPosition = target.PreviousPosition.ToVector2();
                result.UnitPosition       = result.CastTargetPosition;
                result.CollisionResult    = Collision.GetCollisions(immobileFrom, result.CastTargetPosition, range, width, delay, vectorSpeed);

                if (immobileFrom.Distance(result.CastTargetPosition) > vectorLenght - Prediction.GetArrivalTime(immobileFrom.Distance(result.CastTargetPosition), delay, vectorSpeed) * target.MoveSpeed)
                {
                    result.HitChance = HitChance.OutOfRange;
                }

                return(result);
            }

            if (target is AIHeroClient)
            {
                if (((AIHeroClient)target).IsCastingImporantSpell())
                {
                    result.HitChance          = HitChance.VeryHigh;
                    result.CastSourcePosition = immobileFrom;
                    result.CastTargetPosition = target.PreviousPosition.ToVector2();
                    result.UnitPosition       = result.CastTargetPosition;
                    result.CollisionResult    = Collision.GetCollisions(immobileFrom, result.CastTargetPosition, range, width, delay, vectorSpeed);

                    //check if target can dodge with moving backward
                    if (immobileFrom.Distance(result.CastTargetPosition) > range - Prediction.GetArrivalTime(immobileFrom.Distance(result.CastTargetPosition), delay, vectorSpeed) * target.MoveSpeed)
                    {
                        result.HitChance = HitChance.OutOfRange;
                    }

                    return(result);
                }

                //to do: find a fuking logic
                if (avgp < 400 && movt < 100)
                {
                    result.HitChance          = HitChance.High;
                    result.CastTargetPosition = target.PreviousPosition.ToVector2();
                    result.CastSourcePosition = immobileFrom;
                    result.UnitPosition       = result.CastTargetPosition;
                    result.CollisionResult    = Collision.GetCollisions(immobileFrom, result.CastTargetPosition, range, width, delay, vectorSpeed);

                    //check if target can dodge with moving backward
                    if (immobileFrom.Distance(result.CastTargetPosition) > range - Prediction.GetArrivalTime(immobileFrom.Distance(result.CastTargetPosition), delay, vectorSpeed) * target.MoveSpeed)
                    {
                        result.HitChance = HitChance.OutOfRange;
                    }

                    return(result);
                }
            }

            if (target.IsDashing())
            {
                return(Prediction.GetDashingPrediction(target, width, delay, vectorSpeed, range, false, SpellType.Line, immobileFrom, rangeCheckFrom).AsVectorResult(immobileFrom));
            }

            if (Utility.IsImmobileTarget(target))
            {
                return(Prediction.GetImmobilePrediction(target, width, delay, vectorSpeed, range, false, SpellType.Line, immobileFrom, rangeCheckFrom).AsVectorResult(immobileFrom));
            }

            for (int i = 0; i < path.Count - 1; i++)
            {
                Vector2 point = Vector2.Zero;
                if (path[i].Distance(ObjectManager.Player.PreviousPosition) < range)
                {
                    point = path[i];
                }
                else
                {
                    point = Geometry.ClosestCirclePoint(rangeCheckFrom, range, path[i]);
                }

                var res = Prediction.WaypointAnlysis(target, width, delay, vectorSpeed, vectorLenght, false, SpellType.Line, path, avgt, movt, avgp, 360, point);
                res.Input = new Prediction.Input(target, delay, vectorSpeed, width, range, false, SpellType.Line, rangeCheckFrom.ToVector3World(), rangeCheckFrom.ToVector3World());
                res.Lock();
                if (res.HitChance >= HitChance.Low)
                {
                    return(res.AsVectorResult(point));
                }
            }

            result.CastSourcePosition = immobileFrom;
            result.CastTargetPosition = target.PreviousPosition.ToVector2();
            result.HitChance          = HitChance.None;
            return(result);
        }
        /// <summary>
        /// Gets Aoe Prediction result
        /// </summary>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="vectorSpeed">Vector speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="vectorLenght">Vector lenght</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns>
        public static AoeResult GetAoePrediction(float width, float delay, float vectorSpeed, float range, float vectorLenght, Vector2 rangeCheckFrom)
        {
            AoeResult result  = new AoeResult();
            var       enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, rangeCheckFrom).Distance(rangeCheckFrom) < range);

            foreach (var enemy in enemies)
            {
                List <Vector2> path = enemy.GetWaypoints();
                if (path.Count <= 1)
                {
                    Vector2          from      = rangeCheckFrom + (enemy.PreviousPosition.ToVector2() - rangeCheckFrom).Normalized() * range;
                    Vector2          to        = from + (enemy.PreviousPosition.ToVector2() - from).Normalized() * vectorLenght;
                    Collision.Result colResult = Collision.GetCollisions(from, to, range, width, delay, vectorSpeed);

                    if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions))
                    {
                        int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.Type == GameObjectType.AIHeroClient && p.IsValid);
                        if (collisionCount > result.HitCount)
                        {
                            result = new AoeResult
                            {
                                CastSourcePosition = from,
                                CastTargetPosition = enemy.PreviousPosition.ToVector2(),
                                HitCount           = collisionCount,
                                CollisionResult    = colResult
                            };
                        }
                    }
                }
                else
                {
                    if (!enemy.IsDashing())
                    {
                        for (int i = 0; i < path.Count - 1; i++)
                        {
                            Vector2           point      = Geometry.ClosestCirclePoint(rangeCheckFrom, range, path[i]);
                            Prediction.Result prediction = Prediction.GetPrediction(enemy, width, delay, vectorSpeed, vectorLenght, false, SpellType.Line, path, enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), point, rangeCheckFrom);
                            if (prediction.HitChance > HitChance.Medium)
                            {
                                Vector2          to        = point + (prediction.CastPosition - point).Normalized() * vectorLenght;
                                Collision.Result colResult = Collision.GetCollisions(point, to, range, width, delay, vectorSpeed, false);
                                if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions))
                                {
                                    int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.Type == GameObjectType.AIHeroClient && p.IsValid);
                                    if (collisionCount > result.HitCount)
                                    {
                                        result = new AoeResult
                                        {
                                            CastSourcePosition = point,
                                            CastTargetPosition = prediction.CastPosition,
                                            HitCount           = collisionCount,
                                            CollisionResult    = colResult
                                        };
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Пример #7
0
        /// <summary>
        /// Checks minion collisions
        /// </summary>
        /// <param name="from">Start position</param>
        /// <param name="to">End position</param>
        /// <param name="width">Rectangle scale</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="isArc">Checks collision for arc spell</param>
        /// <returns>true if collision found</returns>
        public static bool CheckMinionCollision(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false)
        {
            var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to, width));

            if (isArc)
            {
                spellHitBox = ClipperWrapper.MakePaths(new SPredictionMash.Geometry.Polygon(
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 200 * (to.Distance(from) / 900)),
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 320 * (to.Distance(from) / 900))));
            }
            return(MinionManager.GetMinions(from.Distance(to) + 250, MinionManager.MinionTypes.All, MinionManager.MinionTeam.NotAlly, MinionManager.MinionOrderTypes.None).AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius * 2f + 10f)), spellHitBox)));
        }
Пример #8
0
        /// <summary>
        /// Gets collided units & flags
        /// </summary>
        /// <param name="from">Start position</param>
        /// <param name="to">End position</param>
        /// <param name="width">Rectangle scale</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <returns>Collision result as <see cref="Collision.Result"/></returns>
        public static Result GetCollisions(Vector2 from, Vector2 to, float range, float width, float delay, float missileSpeed = 0, bool isArc = false)
        {
            List <AIBaseClient> collidedUnits = new List <AIBaseClient>();
            var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to.Extend(from, -width), width));

            if (isArc)
            {
                spellHitBox = ClipperWrapper.MakePaths(new SPredictionMash.Geometry.Polygon(
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 200 * (to.Distance(from) / 900)),
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 320 * (to.Distance(from) / 900))));
            }
            Flags _colFlags       = Flags.None;
            var   collidedMinions = MinionManager.GetMinions(range + 100, MinionManager.MinionTypes.All, MinionManager.MinionTeam.NotAlly, MinionManager.MinionOrderTypes.None).AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius + 15)), spellHitBox));
            var   collidedEnemies = GameObjects.EnemyHeroes.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));
            var   collidedAllies  = GameObjects.AllyHeroes.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));

            if (collidedMinions != null && collidedMinions.Count() != 0)
            {
                collidedUnits.AddRange(collidedMinions);
                _colFlags |= Flags.Minions;
            }

            if (collidedEnemies != null && collidedEnemies.Count() != 0)
            {
                collidedUnits.AddRange(collidedEnemies);
                _colFlags |= Flags.EnemyChampions;
            }

            if (collidedAllies != null && collidedAllies.Count() != 0)
            {
                collidedUnits.AddRange(collidedAllies);
                _colFlags |= Flags.AllyChampions;
            }

            if (CheckWallCollision(from, to))
            {
                _colFlags |= Flags.Wall;
            }

            if (CheckYasuoWallCollision(from, to, width))
            {
                _colFlags |= Flags.YasuoWall;
            }

            return(new Result(collidedUnits, _colFlags));
        }
Пример #9
0
        /// <summary>
        /// Checks enemy hero collisions
        /// </summary>
        /// <param name="from">Start position</param>
        /// <param name="to">End position</param>
        /// <param name="width">Rectangle scale</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="isArc">Checks collision for arc spell</param>
        /// <returns>true if collision found</returns>
        public static bool CheckAllyHeroCollision(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false)
        {
            var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to, width));

            if (isArc)
            {
                spellHitBox = ClipperWrapper.MakePaths(new SPredictionMash.Geometry.Polygon(
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 200 * (to.Distance(from) / 900)),
                                                           ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 900), 410, 320 * (to.Distance(from) / 900))));
            }
            return(GameObjects.AllyHeroes.AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox)));
        }