Пример #1
0
            public Geometry.Polygon ToPolygon(int extraRadius = 0)
            {
                var          result      = new Geometry.Polygon();
                const double Step        = 2 * Math.PI / Quality;
                var          outerRadius = (extraRadius + this.OuterRadius) / (float)Math.Cos(Step);
                var          innerRadius = (this.InnerRadius - extraRadius) / (float)Math.Cos(Step);

                var outerAngle = (double)this.OuterRadius;

                for (var i = 0; i <= Quality; i++)
                {
                    outerAngle += Step;
                    result.Add(
                        new Vector2(
                            this.Center.X + outerRadius * (float)Math.Cos(outerAngle),
                            this.Center.Y + outerRadius * (float)Math.Sin(outerAngle)));
                }

                var innerAngle = (double)this.InnerRadius;

                for (var i = 0; i <= Quality; i++)
                {
                    innerAngle += Step;
                    result.Add(
                        new Vector2(
                            this.Center.X + innerRadius * (float)Math.Cos(innerAngle),
                            this.Center.Y + innerRadius * (float)Math.Sin(innerAngle)));
                }

                return(result);
            }
Пример #2
0
        public LaneStatusTracker()
        {
            BottomLanePolyA.Add(new Vector2(12058, 2633));
            BottomLanePolyA.Add(new Vector2(14617, 547));
            BottomLanePolyA.Add(new Vector2(1981, 774));
            BottomLanePolyA.Add(new Vector2(2012, 1635));

            BottomLanePolyB.Add(new Vector2(12058, 2633));
            BottomLanePolyB.Add(new Vector2(14617, 547));
            BottomLanePolyB.Add(new Vector2(13843, 12905));
            BottomLanePolyB.Add(new Vector2(13166, 12802));

            MiddleLanePolyA.Add(new Vector2(2384, 1626));
            MiddleLanePolyA.Add(new Vector2(1578, 2371));
            MiddleLanePolyA.Add(new Vector2(6860, 7900));
            MiddleLanePolyA.Add(new Vector2(7850, 6870));

            MiddleLanePolyB.Add(new Vector2(12422, 13252));
            MiddleLanePolyB.Add(new Vector2(13291, 12332));
            MiddleLanePolyB.Add(new Vector2(7850, 6870));
            MiddleLanePolyB.Add(new Vector2(6800, 7900));

            TopLanePolyA.Add(new Vector2(3021, 12006));
            TopLanePolyA.Add(new Vector2(550, 14358));
            TopLanePolyA.Add(new Vector2(800, 2000));
            TopLanePolyA.Add(new Vector2(1732, 1933));

            TopLanePolyB.Add(new Vector2(3021, 12006));
            TopLanePolyB.Add(new Vector2(550, 14358));
            TopLanePolyB.Add(new Vector2(12531, 14101));
            TopLanePolyB.Add(new Vector2(12651, 13203));

            Drawing.OnDraw += Drawing_OnDraw;
        }
Пример #3
0
 public static CustomPolygon CreateTargetedSpell(SpellInfo info, Vector3 startPosition, GameObject target)
 {
     Geometry.Polygon line = new Geometry.Polygon();
     line.Add(startPosition);
     line.Add(target.Position);
     return(new CustomPolygon(line, info));
 }
Пример #4
0
        /// <summary>
        ///     Creates this instance.
        /// </summary>
        private void Create()
        {
            var wwCenter = GlobalVariables.Player.ServerPosition.Extend(this.Start.To3D(), 300);

            this.CastPosition = wwCenter.To2D();

            var wwPerpend = (wwCenter - GlobalVariables.Player.ServerPosition).Normalized();

            wwPerpend.X = -wwPerpend.X;

            var leftInnerBound = wwCenter.Extend(wwPerpend,
                                                 (GlobalVariables.Spells[SpellSlot.W].Width / 2) + this.AdditionalWidth);
            var rightInnerBound = wwCenter.Extend(wwPerpend,
                                                  -(GlobalVariables.Spells[SpellSlot.W].Width / 2) - this.AdditionalWidth);

            var leftOuterBound  = this.Start.Extend(leftInnerBound.To2D(), this.Range);
            var rightOuterBound = this.Start.Extend(rightInnerBound.To2D(), this.Range);

            var safeZone = new Geometry.Polygon();

            safeZone.Add(leftInnerBound);
            safeZone.Add(rightInnerBound);
            safeZone.Add(leftOuterBound);
            safeZone.Add(rightOuterBound);
            safeZone.Add(new Geometry.Polygon.Arc(leftOuterBound, this.Start, 250 * (float)Math.PI / 180, this.Range));

            this.polygon = safeZone;
        }
Пример #5
0
        private Geometry.Polygon GetPoly(Vector3 castPos)
        {
            var eWidth    = 200;
            var startPos  = player.ServerPosition.Extend(castPos, player.Distance(castPos) - 100);
            var endPos    = player.ServerPosition.Extend(castPos, player.Distance(castPos) + 400);
            var direction = (endPos.To2D() - startPos.To2D()).Normalized();

            var pos1 = (startPos.To2D() - direction.Perpendicular() * eWidth / 2f).To3D();

            var pos2 =
                (endPos.To2D() + (endPos.To2D() - startPos.To2D()).Normalized() +
                 direction.Perpendicular() * eWidth / 2f).To3D();

            var pos3 = (startPos.To2D() + direction.Perpendicular() * eWidth / 2f).To3D();

            var pos4 =
                (endPos.To2D() + (endPos.To2D() - startPos.To2D()).Normalized() -
                 direction.Perpendicular() * eWidth / 2f).To3D();
            var poly = new Geometry.Polygon();

            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return(poly);
        }
Пример #6
0
            public Geometry.Polygon ToPolygon(int extraRadius = 0)
            {
                extraRadius += this.Radius;
                var result      = new Geometry.Polygon();
                var outerRadius = (0.35256f * this.Distance + 133f) / (float)Math.Cos(2 * Math.PI / Quality);
                var innerRadius = -0.1562f * this.Distance + 687.31f;
                var outerCenter = Geometry.CircleCircleIntersection(this.Start, this.End, outerRadius, outerRadius)[0];
                var innerCenter = Geometry.CircleCircleIntersection(this.Start, this.End, innerRadius, innerRadius)[0];

                var dir  = (this.End - outerCenter).Normalized();
                var step = -(float)(dir.AngleBetween((this.Start - outerCenter).Normalized()) * Math.PI / 180) / Quality;

                for (var i = 0; i < Quality; i++)
                {
                    result.Add(outerCenter + (outerRadius + 15 + extraRadius) * dir.Rotated(step * i));
                }

                dir  = (this.Start - innerCenter).Normalized();
                step = (float)(dir.AngleBetween((this.End - innerCenter).Normalized()) * Math.PI / 180) / Quality;

                for (var i = 0; i < Quality; i++)
                {
                    result.Add(innerCenter + Math.Max(0, innerRadius - extraRadius - 100) * dir.Rotated(step * i));
                }

                return(result);
            }
Пример #7
0
    public void draw_circle_on_minimap(SharpDX.Vector3 center, float radius, System.Drawing.Color color, float thickness, int quality)
    {
        Geometry.Polygon result = new Geometry.Polygon();

        result.Add(new SharpDX.Vector3(0, 0, 0));
        result.Add(new SharpDX.Vector3(0, 14800, 0));
        result.Add(new SharpDX.Vector3(14800, 14800, 0));
        result.Add(new SharpDX.Vector3(14800, 0, 0));

        List <SharpDX.Vector3> points = new List <SharpDX.Vector3>();

        for (var i = 1; i <= quality; ++i)
        {
            var angle = i * 2 * Math.PI / quality;
            points.Add(new SharpDX.Vector3(center.X + radius * (float)(Math.Cos(angle)), center.Y + radius * (float)(Math.Sin(angle)), 0));
        }

        for (var i = 0; i < points.Count; ++i)
        {
            var start = points[i];
            var end   = points[points.Count - 1 == i ? 0 : i + 1];
            if (!result.IsInside(start) && !result.IsInside(end))
            {
                continue;
            }

            DrawingInternal.AddLineOnScreen(Drawing.WorldToMinimap(start).To3D(), Drawing.WorldToMinimap(end).To3D(), color, thickness);
        }
    }
Пример #8
0
        public static CustomPolygon CreateTargetedSpell(SpellInfo info, Vector3 startPosition, Vector3 endPosition)
        {
            //these posistions could have to be put as worldtoscreen
            Geometry.Polygon line = new Geometry.Polygon();
            line.Add(startPosition);
            line.Add(endPosition);

            return(new CustomPolygon(line, info));
        }
Пример #9
0
        public Geometry.Polygon ToSimplePolygon()
        {
            var poly = new Geometry.Polygon();

            poly.Add(RotateAroundPoint(FixedStartPosition.To2D(), FixedEndPosition.To2D(), -OwnSpellData.ConeAngle / 2f * (float)Math.PI / 180));
            poly.Add(RotateAroundPoint(FixedStartPosition.To2D(), FixedEndPosition.To2D(), +OwnSpellData.ConeAngle / 2f * (float)Math.PI / 180));
            poly.Add(FixedStartPosition);
            return(poly);
        }
Пример #10
0
        public static CustomPolygon CreateRectangleAroundPoint(ParticleInfo info, int length, int width, Vector3 position, int xoffset = 0, int yoffset = 0)
        {
            Geometry.Polygon rect = new Geometry.Polygon();

            rect.Add(new Vector3(position.X - (length / 2) + xoffset, position.Y - (width / 2) + yoffset, position.Z));
            rect.Add(new Vector3(position.X + (length / 2) + xoffset, position.Y - (width / 2) + yoffset, position.Z));
            rect.Add(new Vector3(position.X - (length / 2) + xoffset, position.Y + (width / 2) + yoffset, position.Z));
            rect.Add(new Vector3(position.X + (length / 2) + xoffset, position.Y + (width / 2) + yoffset, position.Z));

            return(new CustomPolygon(rect, info));
        }
Пример #11
0
        /// <summary>
        /// Returns polygon + circleCenter
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public Tuple <Geometry.Polygon, Vector2> ToPolygonA(int offset = 0)
        {
            offset += HitBox;
            var result = new Geometry.Polygon();

            var innerRadius = -0.1562f * Distance + 687.31f;
            var outerRadius = 0.35256f * Distance + 133f;

            outerRadius = outerRadius / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN);

            var innerCenters = CircleCircleIntersection(Start, End, innerRadius, innerRadius);
            var outerCenters = CircleCircleIntersection(Start, End, outerRadius, outerRadius);

            var innerCenter = innerCenters.FirstOrDefault();
            var outerCenter = outerCenters.FirstOrDefault();

            if (innerCenters.Count() == 0 || outerCenters.Count() == 0)
            {
                return(new Tuple <Geometry.Polygon, Vector2>(null, new Vector2()));
            }

            var a = new Vector2(End.X + 0, End.Y + 100);
            //Render.Circle.DrawCircle(innerCenter.To3D(), 100, Color.White);

            var direction = (End - outerCenter).Normalized();
            var end       = (Start - outerCenter).Normalized();
            var maxAngle  = (float)(direction.AngleBetween(end) * Math.PI / 180);

            var step = -maxAngle / CircleLineSegmentN;

            //outercircle
            for (int i = 0; i < CircleLineSegmentN; i++)
            {
                var angle = step * i;
                var point = outerCenter + (outerRadius + 15 + offset) * direction.Rotated(angle);
                result.Add(point);
            }

            direction = (Start - innerCenter).Normalized();
            end       = (End - innerCenter).Normalized();
            maxAngle  = (float)(direction.AngleBetween(end) * Math.PI / 180);
            step      = maxAngle / CircleLineSegmentN;
            //outercircle
            for (int i = 0; i < CircleLineSegmentN; i++)
            {
                var angle = step * i;
                var point = innerCenter + Math.Max(0, innerRadius - offset - 100) * direction.Rotated(angle);
                result.Add(point);
            }

            return(new Tuple <Geometry.Polygon, Vector2>(result, a));
        }
Пример #12
0
            public Geometry.Polygon ToPolygon(int extraRadius = 0, float overrideRadius = -1)
            {
                var result = new Geometry.Polygon();
                var radius = (overrideRadius > 0 ? overrideRadius : this.Radius + extraRadius) * this.Perpendicular;
                var dir    = extraRadius * this.Direction;

                result.Add(this.Start + radius - dir);
                result.Add(this.Start - radius - dir);
                result.Add(this.End - radius + dir);
                result.Add(this.End + radius + dir);

                return(result);
            }
Пример #13
0
        static Boolean checkYasuoWall(Vector3 enemyPos)
        {
            if (wallCastTick > Environment.TickCount)
            {
                GameObject wall = null;
                foreach (var gameObject in ObjectManager.Get <GameObject>())
                {
                    if (gameObject.IsValid && Regex.IsMatch(gameObject.Name, "_w_windwall", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        wall = gameObject;
                        break;
                    }
                }

                if (wall == null)
                {
                    return(false);
                }

                int wallWidth = (300 + 50 * Convert.ToInt32(wall.Name.Substring(wall.Name.Length - 6, 1)));

                var wallDirection = (wall.Position.To2D() - yasuoWallPos).Normalized().Perpendicular();
                var wallStart     = wall.Position.To2D() + wallWidth / 2 * wallDirection;
                var wallEnd       = wallStart - wallWidth * wallDirection;

                Vector2          Direction     = (wallEnd - wallStart).Normalized();
                Vector2          Perpendicular = Direction.Perpendicular();
                Geometry.Polygon wallPolygon   = new Geometry.Polygon();

                int widthWall = 75;
                wallPolygon.Add(wallStart + widthWall * Perpendicular);
                wallPolygon.Add(wallStart - widthWall * Perpendicular);
                wallPolygon.Add(wallEnd - widthWall * Perpendicular);
                wallPolygon.Add(wallEnd + widthWall * Perpendicular);

                int polygonCounts = wallPolygon.Points.Count;
                for (var i = 0; i < polygonCounts; i++)
                {
                    var inter = wallPolygon.Points[i].Intersection(wallPolygon.Points[i != polygonCounts - 1 ? i + 1 : 0], player.ServerPosition.To2D(), enemyPos.To2D());
                    if (inter.Intersects)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #14
0
            public Geometry.Polygon ToPolygon(int extraRadius = 0)
            {
                var result = new Geometry.Polygon();

                result.Add(this.Center);
                var radius = (this.Range + extraRadius) / (float)Math.Cos(2 * Math.PI / Quality);
                var side   = this.Direction.Rotated(-this.Radius * 0.5f);

                for (var i = 0; i <= Quality; i++)
                {
                    var dir = side.Rotated(i * this.Radius / Quality).Normalized();
                    result.Add(new Vector2(this.Center.X + radius * dir.X, this.Center.Y + radius * dir.Y));
                }

                return(result);
            }
Пример #15
0
        public override Geometry.Polygon ToPolygon()
        {
            var endPolygon = new Geometry.Polygon();
            List <Geometry.Polygon.Circle> circles = new List <Geometry.Polygon.Circle>();

            for (int i = -30; i <= 30; i += 10)
            {
                var rotatedDirection = Direction.Rotated(i * (float)Math.PI / 180);
                var c = new Geometry.Polygon.Circle(StartPosition + rotatedDirection.To3D() * distance, OwnSpellData.Radius);
                circles.Add(c);
            }

            //var circlePointsList = circles.Select(x => x.Points.Where(circlePoint =>
            //     circles.Where(otherCircle => otherCircle != x).All(y => !y.IsInside(circlePoint))
            //)).ToList();
            var circlePointsList = circles.Select(x => x.Points);

            foreach (var circlePoints in circlePointsList)
            {
                foreach (var p in circlePoints)
                {
                    endPolygon.Add(p);
                }
            }

            return(endPolygon);
        }
Пример #16
0
        public Geometry.Polygon ToSimplePolygon()
        {
            var poly = new Geometry.Polygon();

            poly.Add(FixedStartPosition);
            poly.Points.AddRange(GetEdgePoints());
            return(poly);
        }
Пример #17
0
        static Geometry.Polygon GetDetailedPolygon(this Geometry.Polygon.Rectangle p)
        {
            Geometry.Polygon detailedRectangle = new Geometry.Polygon();
            for (int i = 0; i < p.Points.Count; i += 2)
            {
                var point     = p.Points[i];
                var nextPoint = i == p.Points.Count - 1 ? p.Points[0] : p.Points[i + 1];
                detailedRectangle.Add(nextPoint);

                for (float scaling = 1; scaling >= 0; scaling -= 0.1f)
                {
                    var detailedPoint = point + (nextPoint - point) * scaling;
                    detailedRectangle.Add(detailedPoint);
                }
                detailedRectangle.Add(point);
            }
            return(detailedRectangle);
        }
Пример #18
0
            public Geometry.Polygon ToSDKPolygon(int offset = 0)
            {
                offset += this.HitBox;
                var result = new Geometry.Polygon();

                var innerRadius = -0.1562f * this.Distance + 687.31f;
                var outerRadius = 0.35256f * this.Distance + 133f;

                outerRadius = outerRadius / (float)Math.Cos(2 * Math.PI / 22);

                var innerCenters = CircleCircleIntersection(this.Start, this.End, innerRadius, innerRadius);
                var outerCenters = CircleCircleIntersection(this.Start, this.End, outerRadius, outerRadius);

                var innerCenter = innerCenters[0];
                var outerCenter = outerCenters[0];

                var direction = (this.End - outerCenter).Normalized();
                var end       = (this.Start - outerCenter).Normalized();
                var maxAngle  = (float)(direction.AngleBetween(end) * Math.PI / 180);

                var step = -maxAngle / 22;

                for (var i = 0; i < 22; i++)
                {
                    var angle = step * i;
                    var point = outerCenter + (outerRadius + 15 + offset) * direction.Rotated(angle);
                    result.Add(point);
                }

                direction = (this.Start - innerCenter).Normalized();
                end       = (this.End - innerCenter).Normalized();
                maxAngle  = (float)(direction.AngleBetween(end) * Math.PI / 180);
                step      = maxAngle / 22;
                for (var i = 0; i < 22; i++)
                {
                    var angle = step * i;
                    var point = innerCenter + Math.Max(0, innerRadius - offset - 100) * direction.Rotated(angle);
                    result.Add(point);
                }

                return(result);
            }
Пример #19
0
        /// <summary>
        /// Converts list to polygon
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static Geometry.Polygon ToPolygon(this IEnumerable <Vector2> list)
        {
            var polygon = new Geometry.Polygon();

            foreach (var x in list)
            {
                polygon.Add(x);
            }

            return(polygon);
        }
Пример #20
0
        /// <summary>
        ///     Converts a list of <see cref="IntPoint" />s to a <see cref="Geometry.Polygon" />
        /// </summary>
        /// <param name="list">List of <see cref="Geometry.Polygon" /></param>
        /// <returns>Polygon made up of <see cref="IntPoint" />s</returns>
        public static Geometry.Polygon ToPolygon(this List <IntPoint> list)
        {
            var polygon = new Geometry.Polygon();

            foreach (var point in list)
            {
                polygon.Add(new Vector2(point.X, point.Y));
            }

            return(polygon);
        }
Пример #21
0
        public static Geometry.Polygon GetPolyFromVector(Vector3 from, Vector3 to, float width)
        {
            var POS       = to.Extend(from, from.Distance(to));
            var direction = (POS.To2D() - to.To2D()).Normalized();

            var pos1 = (to.To2D() - direction.Perpendicular() * width / 2f).To3D();

            var pos2 =
                (POS.To2D() + (POS.To2D() - to.To2D()).Normalized() + direction.Perpendicular() * width / 2f).To3D();

            var pos3 = (to.To2D() + direction.Perpendicular() * width / 2f).To3D();

            var pos4 =
                (POS.To2D() + (POS.To2D() - to.To2D()).Normalized() - direction.Perpendicular() * width / 2f).To3D();
            var poly = new Geometry.Polygon();

            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return(poly);
        }
Пример #22
0
        public static Geometry.Polygon GetPoly(this Vector3 castPos)
        {
            const int eRadius   = 100;
            var       startPos  = Player.Instance.ServerPosition.Extend(castPos, Player.Instance.Distance(castPos) - 100);
            var       endPos    = Player.Instance.ServerPosition.Extend(castPos, Player.Instance.Distance(castPos) + 400);
            var       direction = (endPos - startPos).Normalized();

            var pos1 = (startPos - direction.Perpendicular() * (eRadius - 20)).To3D();

            var pos3 = (startPos + direction.Perpendicular() * (eRadius - 20)).To3D();

            var pos2 = (endPos + (endPos - startPos).Normalized() + direction.Perpendicular() * (eRadius + 50)).To3D();

            var pos4 = (endPos + (endPos - startPos).Normalized() - direction.Perpendicular() * (eRadius + 50)).To3D();

            var poly = new Geometry.Polygon();

            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return(poly);
        }
Пример #23
0
        public static Geometry.Polygon GetPoly(Vector3 pos, float range, float width)
        {
            var poss = Shen.ServerPosition.Extend(pos, range);
            var direction = (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized();

            var pos1 = (Shen.ServerPosition.To2D() - direction.Perpendicular()*width/2f).To3D();

            var pos2 =
                (poss.Normalized() + (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized() +
                 direction.Perpendicular()*width/2f).To3D();

            var pos3 = (Shen.ServerPosition.To2D() + direction.Perpendicular()*width/2f).To3D();

            var pos4 =
                (poss.Normalized() + (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized() -
                 direction.Perpendicular()*width/2f).To3D();
            var poly = new Geometry.Polygon();
            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return poly;
        }
Пример #24
0
            public Geometry.Polygon ToSDKPolygon(int offset = 0)
            {
                var result = new Geometry.Polygon();

                var outRadius   = (offset + this.Radius + this.RingRadius) / (float)Math.Cos(2 * Math.PI / 22);
                var innerRadius = this.Radius - this.RingRadius - offset;

                for (var i = 0; i <= 22; i++)
                {
                    var angle = i * 2 * Math.PI / 22;
                    var point = new Vector2(this.Center.X - outRadius * (float)Math.Cos(angle), this.Center.Y - outRadius * (float)Math.Sin(angle));
                    result.Add(point);
                }

                for (var i = 0; i <= 22; i++)
                {
                    var angle = i * 2 * Math.PI / 22;
                    var point = new Vector2(this.Center.X + innerRadius * (float)Math.Cos(angle), this.Center.Y - innerRadius * (float)Math.Sin(angle));
                    result.Add(point);
                }

                return(result);
            }
Пример #25
0
        public static Geometry.Polygon GetPoly(Vector3 pos, float range, float width)
        {
            var poss      = Shen.ServerPosition.Extend(pos, range);
            var direction = (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized();

            var pos1 = (Shen.ServerPosition.To2D() - direction.Perpendicular() * width / 2f).To3D();

            var pos2 =
                (poss.Normalized() + (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized() +
                 direction.Perpendicular() * width / 2f).To3D();

            var pos3 = (Shen.ServerPosition.To2D() + direction.Perpendicular() * width / 2f).To3D();

            var pos4 =
                (poss.Normalized() + (poss.Normalized() - Shen.ServerPosition.To2D()).Normalized() -
                 direction.Perpendicular() * width / 2f).To3D();
            var poly = new Geometry.Polygon();

            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return(poly);
        }
Пример #26
0
        private Geometry.Polygon GetPoly(Vector3 pos)
        {
            var POS       = player.ServerPosition.Extend(pos, Q.ChargedMaxRange);
            var direction = (POS.To2D() - player.ServerPosition.To2D()).Normalized();

            var pos1 = (player.ServerPosition.To2D() - direction.Perpendicular() * qWidth / 2f).To3D();

            var pos2 =
                (POS.To2D() + (POS.To2D() - player.ServerPosition.To2D()).Normalized() +
                 direction.Perpendicular() * qWidth / 2f).To3D();

            var pos3 = (player.ServerPosition.To2D() + direction.Perpendicular() * qWidth / 2f).To3D();

            var pos4 =
                (POS.To2D() + (POS.To2D() - player.ServerPosition.To2D()).Normalized() -
                 direction.Perpendicular() * qWidth / 2f).To3D();
            var poly = new Geometry.Polygon();

            poly.Add(pos1);
            poly.Add(pos3);
            poly.Add(pos2);
            poly.Add(pos4);
            return(poly);
        }
Пример #27
0
 static void Drawing_OnDraw(EventArgs args)
 {
     if (Config.Item("Write").GetValue <KeyBind>().Active)
     {
         if (Poly.Points.All(pa => pa != Game.CursorPos.To2D()))
         {
             Poly.Add(Game.CursorPos.To2D());
             Game.PrintChat(Game.CursorPos.ToString());
             using (StreamWriter sw = File.AppendText("C:/Vector.txt"))
             {
                 sw.WriteLine("new Vector2(" + Game.CursorPos.To2D().X + "," + Game.CursorPos.Y + ");");
                 sw.Close();
             }
         }
     }
 }
Пример #28
0
            public Geometry.Polygon ToPolygon(int extraRadius = 0, float overrideRadius = -1)
            {
                var          result = new Geometry.Polygon();
                const double Step   = 2 * Math.PI / Quality;
                var          radius = overrideRadius > 0 ? overrideRadius : (extraRadius + this.Radius) / (float)Math.Cos(Step);
                var          angle  = (double)this.Radius;

                for (var i = 0; i <= Quality; i++)
                {
                    angle += Step;
                    result.Add(
                        new Vector2(
                            this.Center.X + radius * (float)Math.Cos(angle),
                            this.Center.Y + radius * (float)Math.Sin(angle)));
                }

                return(result);
            }
Пример #29
0
		private static void getAllUnsafePositions()
		{
			List<Geometry.Polygon> dangerousPositions = new List<Geometry.Polygon>();
			foreach (var Hero in ObjectManager.Get<Obj_AI_Hero>())
			{
				var Q = Hero.Spellbook.GetSpell(SpellSlot.Q);
				var W = Hero.Spellbook.GetSpell(SpellSlot.W);
				var E = Hero.Spellbook.GetSpell(SpellSlot.E);
				var R = Hero.Spellbook.GetSpell(SpellSlot.R);
				var AARange = Hero.AttackRange;
				List<float> Ranges = new List<float>();
				if (Q.SData.CastRange <= 900 && Q.Cooldown <= 0)//filter global skillshots and Spells on cooldown
				{
					Ranges.Add(Q.SData.CastRange);
				}
				if (W.SData.CastRange <= 900 && W.Cooldown <= 0)//filter global skillshots and Spells on cooldown
				{
					Ranges.Add(W.SData.CastRange);
				}
				if (E.SData.CastRange <= 900 && E.Cooldown <= 0)//filter global skillshots and Spells on cooldown
				{
					Ranges.Add(E.SData.CastRange);
				}
				if (R.SData.CastRange <= 900 && R.Cooldown <= 0)//filter global skillshots and Spells on cooldown
				{
					Ranges.Add(R.SData.CastRange);
				}
				Ranges.Add(AARange);
				float maxRange = Ranges.Max();
				var Poly = new Geometry.Polygon();
				int sensitivity = 60;
				for(int i = 0; i < sensitivity; i ++){//Todo, allow user interactivity
					var Circle = new Vector2(Hero.Position + maxRange * Math.Cos(360/sensitivity), Hero.Position + maxRange * Math.Sin(360/sensitivity));
					Poly.Add(Circle);
				}
				dangerousPositions.Add(Poly);
			}
			return dangerousPositions;
		}
Пример #30
0
        public static CustomPolygon CreateArc(SpellInfo info, Vector3 sourcePosition, Vector3 endPosition, float width)
        {
            Vector3 cursorPos = new Vector3(endPosition.X, endPosition.Y, NavMesh.GetHeightForPosition(endPosition.X, endPosition.Y));

            double norm = Math.Sqrt(Math.Pow(cursorPos.X - sourcePosition.X, 2) + Math.Pow(cursorPos.Y - sourcePosition.Y, 2)),
                   s    = norm / 2,
                   d    = s * (1 - cursorPos.LengthSquared()) / cursorPos.LengthSquared(),
                   u    = (cursorPos.X - sourcePosition.X) / norm,
                   v    = (cursorPos.Y - sourcePosition.Y) / norm,
                   c1   = v * d + (sourcePosition.X + cursorPos.X) / 2,
                   c2   = -u * d + (sourcePosition.Y + cursorPos.Y) / 2;

            Vector3 centerPoint   = new Vector3((float)c1, (float)c2, cursorPos.Z);
            int     angleOfPlayer = (int)MathUtil.RadiansToDegrees((float)Math.Atan2(sourcePosition.Y - centerPoint.Y, sourcePosition.X - centerPoint.X)),
                    angleOfCursor = (int)MathUtil.RadiansToDegrees((float)Math.Atan2(cursorPos.Y - centerPoint.Y, cursorPos.X - centerPoint.X));

            float radius = centerPoint.Distance(sourcePosition) + width;

            //arc circle
            //Drawing.DrawCircle(centerPoint, radius, drawColor);

            Geometry.Polygon arc = new Geometry.Polygon();
            //arc.Add(centerPoint);
            //arc.Add(sourcePosition);

            foreach (int i in GetAllAnglesBetween(angleOfPlayer, angleOfCursor))
            {
                float   angleInRadians = MathUtil.DegreesToRadians(i);
                Vector2 test           = new Vector2((float)(centerPoint.X + radius * Math.Cos(angleInRadians)),
                                                     (float)(centerPoint.Y + radius * Math.Sin(angleInRadians)));
                arc.Add(centerPoint.Extend(test, radius).To3D((int)cursorPos.Z));
                // Drawing.DrawLine(centerPoint.WorldToScreen(), centerPoint.Extend(test, radius).To3D().WorldToScreen(), 5f, Geometry.drawColor);
            }

            return(new CustomPolygon(arc, info));
        }
Пример #31
0
        /// <summary>
        /// Converts list to polygon
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static Geometry.Polygon ToPolygon(this IEnumerable<Vector2> list)
        {
            var polygon = new Geometry.Polygon();

            foreach (var x in list)
            {
                polygon.Add(x);
            }

            return polygon;
        }
Пример #32
0
        private static void OnLoadingComplete(EventArgs args)
        {
            // Create the config folder
            Directory.CreateDirectory(ConfigFolderPath);

            // Initialize menu
            Menu = MainMenu.AddMenu("MasterMind", "MasterMind", "MasterMind - Improve Yourself!");

            Menu.AddGroupLabel("Welcome to MasterMind, your solution for quality game assistance.");
            Menu.AddLabel("This addon offers some neat features which will improve your gameplay");
            Menu.AddLabel("without dropping FPS or gameplay fun.");
            Menu.AddSeparator();
            Menu.AddLabel("Take a look at the various sub menus this addon has to offer, have fun!");

            // Initialize properties
            IsSpectatorMode = Bootstrap.IsSpectatorMode;

            // Initialize components
            foreach (var component in Components.Where(component => component.ShouldLoad(IsSpectatorMode)))
            {
                component.InitializeComponent();
            }

            return;

            // TODO: Remove debug
            Task.Run(() =>
            {
                // Get all brushes on the map
                Logger.Debug("[Brushes] NavMesh.Width {0} | Height {1} | CellWith {2} | CellHeight {3}", NavMesh.Width, NavMesh.Height, NavMesh.CellWidth, NavMesh.CellHeight);

                var brushes = new Dictionary<int, List<Geometry.Polygon>>();
                var offset = NavMesh.GridToWorld(0, 0).To2D();
                var cellSize = NavMesh.CellHeight;
                Logger.Debug("[Brushes] Cell size: " + cellSize);
                for (var cellX = 0; cellX < NavMesh.Width; cellX++)
                {
                    for (var cellY = 165; cellY < 400; cellY++)
                    {
                        // Get grid and cell
                        var cell = NavMesh.GetCell(cellX, cellY);
                        var worldPos = offset + new Vector2(cellX * cellSize, cellY * cellSize);

                        // Check for brush
                        if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                        {
                            // Check if already existing brush
                            var collection = brushes.Values.FirstOrDefault(o => o.Any(p => p.CenterOfPolygon().Distance(worldPos, true) < (cellSize * 3).Pow()));
                            if (collection == null)
                            {
                                // Create a new brush pair
                                Logger.Debug("[Brushes] Creating new pair of brush points, total so far: " + (brushes.Count + 1));
                                collection = new List<Geometry.Polygon>();
                                brushes.Add(brushes.Count, collection);
                            }

                            // Add the point to the collection
                            var cellPolygon = new Geometry.Polygon();
                            cellPolygon.Add(worldPos);
                            cellPolygon.Add(worldPos + new Vector2(0, cellSize));
                            cellPolygon.Add(worldPos + cellSize);
                            cellPolygon.Add(worldPos + new Vector2(cellSize, 0));
                            collection.Add(cellPolygon);
                        }
                    }
                }

                Logger.Debug("[Brushes] The result:\n" + string.Join("\n", brushes.Values.Select(o => o.Count)));

                // Convert brush points to polygons
                var polyBrushes = new Dictionary<int, Geometry.Polygon>();
                foreach (var brushEntry in brushes)
                {
                    var brushPoly = brushEntry.Value.JoinPolygons().FirstOrDefault();
                    if (brushPoly != null)
                    {
                        polyBrushes.Add(brushEntry.Key, brushPoly);
                    }
                }

                // Draw all brushes
                Logger.Debug("[Brushes] Ready to draw {0} brush polygons!", polyBrushes.Count);
                Core.DelayAction(() =>
                {
                    Drawing.OnDraw += delegate
                    {
                        foreach (var polyList in brushes)
                        {
                            foreach (var poly in polyList.Value)
                            {
                                //poly.Draw(System.Drawing.Color.LawnGreen, 2);
                            }
                        }

                        foreach (var polyBrush in polyBrushes)
                        {
                            //Circle.Draw(Color.LawnGreen, NavMesh.CellHeight, polyBrush.Value.Points.Select(o => o.To3DWorld()).ToArray());
                            polyBrush.Value.Draw(System.Drawing.Color.Red, 2);
                            Drawing.DrawText(polyBrush.Value.CenterOfPolygon().To3DWorld().WorldToScreen(), System.Drawing.Color.GreenYellow, polyBrush.Key.ToString(), 10);
                        }
                    };
                }, 0);
            });
        }
Пример #33
0
        /// <summary>
        ///     Converts a list of <see cref="IntPoint" />s to a <see cref="Geometry.Polygon" />
        /// </summary>
        /// <param name="list">List of <see cref="Geometry.Polygon" /></param>
        /// <returns>Polygon made up of <see cref="IntPoint" />s</returns>
        public static Geometry.Polygon ToPolygon(this List<IntPoint> list)
        {
            var polygon = new Geometry.Polygon();
            foreach (var point in list)
            {
                polygon.Add(new Vector2(point.X, point.Y));
            }

            return polygon;
        }
Пример #34
0
 /// <summary>
 /// Returns a polygon that contains each position of a team champion
 /// </summary>
 /// <param name="allyTeam">returns the polygon for ally team if true, enemy if false</param>
 /// <returns></returns>
 internal static Geometry.Polygon GetTeamPolygon(bool allyTeam = true)
 {
     var poly = new Geometry.Polygon();
     foreach (var v2 in allyTeam ? GetAllyPosList() : GetEnemyPosList())
     {
         poly.Add(v2);
     }
     poly.ToClipperPath();
     return poly;
 }
Пример #35
0
        private static void OnLoadingComplete(EventArgs args)
        {
            // Create the config folder
            Directory.CreateDirectory(ConfigFolderPath);

            // Initialize menu
            Menu = MainMenu.AddMenu("MasterMind", "MasterMind", "MasterMind - Improve Yourself!");

            Menu.AddGroupLabel("Welcome to MasterMind, your solution for quality game assistance.");
            Menu.AddLabel("This addon offers some neat features which will improve your gameplay");
            Menu.AddLabel("without dropping FPS or gameplay fun.");
            Menu.AddSeparator();
            Menu.AddLabel("Take a look at the various sub menus this addon has to offer, have fun!");

            // Initialize properties
            IsSpectatorMode = Bootstrap.IsSpectatorMode;

            // Initialize components
            foreach (var component in Components.Where(component => component.ShouldLoad(IsSpectatorMode)))
            {
                component.InitializeComponent();
            }

            return;

            // TODO: Remove debug
            Task.Run(() =>
            {
                // Get all brushes on the map
                Logger.Debug("[Brushes] NavMesh.Width {0} | Height {1} | CellWith {2} | CellHeight {3}", NavMesh.Width, NavMesh.Height, NavMesh.CellWidth, NavMesh.CellHeight);

                var brushes  = new Dictionary <int, List <Geometry.Polygon> >();
                var offset   = NavMesh.GridToWorld(0, 0).To2D();
                var cellSize = NavMesh.CellHeight;
                Logger.Debug("[Brushes] Cell size: " + cellSize);
                for (var cellX = 0; cellX < NavMesh.Width; cellX++)
                {
                    for (var cellY = 165; cellY < 400; cellY++)
                    {
                        // Get grid and cell
                        var cell     = NavMesh.GetCell(cellX, cellY);
                        var worldPos = offset + new Vector2(cellX * cellSize, cellY * cellSize);

                        // Check for brush
                        if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                        {
                            // Check if already existing brush
                            var collection = brushes.Values.FirstOrDefault(o => o.Any(p => p.CenterOfPolygon().Distance(worldPos, true) < (cellSize * 3).Pow()));
                            if (collection == null)
                            {
                                // Create a new brush pair
                                Logger.Debug("[Brushes] Creating new pair of brush points, total so far: " + (brushes.Count + 1));
                                collection = new List <Geometry.Polygon>();
                                brushes.Add(brushes.Count, collection);
                            }

                            // Add the point to the collection
                            var cellPolygon = new Geometry.Polygon();
                            cellPolygon.Add(worldPos);
                            cellPolygon.Add(worldPos + new Vector2(0, cellSize));
                            cellPolygon.Add(worldPos + cellSize);
                            cellPolygon.Add(worldPos + new Vector2(cellSize, 0));
                            collection.Add(cellPolygon);
                        }
                    }
                }

                Logger.Debug("[Brushes] The result:\n" + string.Join("\n", brushes.Values.Select(o => o.Count)));

                // Convert brush points to polygons
                var polyBrushes = new Dictionary <int, Geometry.Polygon>();
                foreach (var brushEntry in brushes)
                {
                    var brushPoly = brushEntry.Value.JoinPolygons().FirstOrDefault();
                    if (brushPoly != null)
                    {
                        polyBrushes.Add(brushEntry.Key, brushPoly);
                    }
                }

                // Draw all brushes
                Logger.Debug("[Brushes] Ready to draw {0} brush polygons!", polyBrushes.Count);
                Core.DelayAction(() =>
                {
                    Drawing.OnDraw += delegate
                    {
                        foreach (var polyList in brushes)
                        {
                            foreach (var poly in polyList.Value)
                            {
                                //poly.Draw(System.Drawing.Color.LawnGreen, 2);
                            }
                        }

                        foreach (var polyBrush in polyBrushes)
                        {
                            //Circle.Draw(Color.LawnGreen, NavMesh.CellHeight, polyBrush.Value.Points.Select(o => o.To3DWorld()).ToArray());
                            polyBrush.Value.Draw(System.Drawing.Color.Red, 2);
                            Drawing.DrawText(polyBrush.Value.CenterOfPolygon().To3DWorld().WorldToScreen(), System.Drawing.Color.GreenYellow, polyBrush.Key.ToString(), 10);
                        }
                    };
                }, 0);
            });
        }