Lissandra_the_Ice_Goddess.Evade.Geometry.Ring.ToPolygon C# (CSharp) Method

ToPolygon() public method

public ToPolygon ( int offset ) : Polygon
offset int
return Polygon
            public Polygon ToPolygon(int offset = 0)
            {
                var result = new Polygon();

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

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

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


                return result;
            }
        }

Usage Example

Esempio n. 1
0
        public void UpdatePolygon()
        {
            switch (SpellData.Type)
            {
            case SkillShotType.SkillshotCircle:
                Polygon        = Circle.ToPolygon();
                EvadePolygon   = Circle.ToPolygon(ExtraEvadeDistance);
                DrawingPolygon = Circle.ToPolygon(
                    0,
                    !SpellData.AddHitbox
                            ? SpellData.Radius
                            : (SpellData.Radius - ObjectManager.Player.BoundingRadius));
                break;

            case SkillShotType.SkillshotLine:
                Polygon        = Rectangle.ToPolygon();
                DrawingPolygon = Rectangle.ToPolygon(
                    0,
                    !SpellData.AddHitbox
                            ? SpellData.Radius
                            : (SpellData.Radius - ObjectManager.Player.BoundingRadius));
                EvadePolygon = Rectangle.ToPolygon(ExtraEvadeDistance);
                break;

            case SkillShotType.SkillshotMissileLine:
                Polygon        = Rectangle.ToPolygon();
                DrawingPolygon = Rectangle.ToPolygon(
                    0,
                    !SpellData.AddHitbox
                            ? SpellData.Radius
                            : (SpellData.Radius - ObjectManager.Player.BoundingRadius));
                EvadePolygon = Rectangle.ToPolygon(ExtraEvadeDistance);
                break;

            case SkillShotType.SkillshotCone:
                Polygon        = Sector.ToPolygon();
                DrawingPolygon = Polygon;
                EvadePolygon   = Sector.ToPolygon(ExtraEvadeDistance);
                break;

            case SkillShotType.SkillshotRing:
                Polygon        = Ring.ToPolygon();
                DrawingPolygon = Polygon;
                EvadePolygon   = Ring.ToPolygon(ExtraEvadeDistance);
                break;
            }
        }
Geometry.Ring