コード例 #1
0
ファイル: Spell.cs プロジェクト: giaanthunder/EloBuddy
        //edited
        public static bool LineIntersectLinearSpellEx(this Spell spell, Vector2 a, Vector2 b, out Vector2 intersection)
        {
            var myBoundingRadius = ObjectManager.Player.BoundingRadius;
            var spellDir = spell.Direction;
            var pSpellDir = spell.Direction.Perpendicular();
            var spellRadius = spell.Radius;
            var spellPos = spell.CurrentSpellPosition - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos = spell.GetSpellEndPosition() + spellDir * myBoundingRadius; //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            List<Geometry.IntersectionResult> intersects = new List<Geometry.IntersectionResult>();
            Vector2 heroPos = ObjectManager.Player.ServerPosition.To2D();

            intersects.Add(a.Intersection(b, startRightPos, startLeftPos));
            intersects.Add(a.Intersection(b, endRightPos, endLeftPos));
            intersects.Add(a.Intersection(b, startRightPos, endRightPos));
            intersects.Add(a.Intersection(b, startLeftPos, endLeftPos));

            var sortedIntersects = intersects.Where(i => i.Intersects).OrderBy(i => i.Point.Distance(heroPos)); //Get first intersection

            if (sortedIntersects.Count() > 0)
            {
                intersection = sortedIntersects.First().Point;
                return true;
            }

            intersection = Vector2.Zero;
            return false;
        }
コード例 #2
0
ファイル: MathUtils.cs プロジェクト: bongy97/LeagueSharp-1
 public static bool CheckLineIntersection(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
 {
     return a.Intersection(b, c, d).Intersects;
 }
コード例 #3
0
ファイル: EvadeHelper.cs プロジェクト: qktlfflzk/Backup5.4
        public static bool LineIntersectLinearSpellEx(Vector2 a, Vector2 b, Spell spell, out Vector2 intersection)
        {
            var myBoundingRadius = myHero.BoundingRadius;
            var spellDir = spell.direction;
            var pSpellDir = spell.direction.Perpendicular();
            var spellRadius = GetSpellRadius(spell);
            var spellPos = SpellDetector.GetCurrentSpellPosition(spell) - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos = spell.endPos + spellDir * myBoundingRadius; //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            var int1 = a.Intersection(b, startRightPos, startLeftPos);

            var int2 = a.Intersection(b, endRightPos, endLeftPos);
            var int3 = a.Intersection(b, startRightPos, endRightPos);
            var int4 = a.Intersection(b, startLeftPos, endLeftPos);

            if (int1.Intersects)
            {
                intersection = int1.Point;
                return true;
            }
            else if (int2.Intersects)
            {
                intersection = int2.Point;
                return true;
            }
            else if (int3.Intersects)
            {
                intersection = int3.Point;
                return true;
            }
            else if (int4.Intersects)
            {
                intersection = int4.Point;
                return true;
            }

            intersection = Vector2.Zero;

            return false;
        }