Aka_s_Vayne.Logic.AJSGeometry.ClipPolygons C# (CSharp) Method

ClipPolygons() public static method

public static ClipPolygons ( List polygons ) : System.Collections.Generic.List>
polygons List
return System.Collections.Generic.List>
        public static Paths ClipPolygons(List<Polygon> polygons)
        {
            var subj = new Paths(polygons.Count);
            var clip = new Paths(polygons.Count);

            foreach (var polygon in polygons)
            {
                subj.Add(polygon.ToClipperPath());
                clip.Add(polygon.ToClipperPath());
            }

            var solution = new Paths();
            var c = new Clipper();
            c.AddPaths(subj, PolyType.ptSubject, true);
            c.AddPaths(clip, PolyType.ptClip, true);
            c.Execute(ClipType.ctUnion, solution, PolyFillType.pftPositive, PolyFillType.pftEvenOdd);

            return solution;
        }

Usage Example

Esempio n. 1
0
        static List <Vector2> GetEnemyPoints(bool dynamic = true)
        {
            var staticRange  = 360f;
            var polygonsList = Variables.EnemiesClose.Select(enemy => new AJSGeometry.Circle(enemy.ServerPosition.To2D(), (dynamic ? (enemy.IsMelee ? enemy.AttackRange * 1.5f : enemy.AttackRange) : staticRange) + enemy.BoundingRadius + 20).ToPolygon()).ToList();
            var pathList     = AJSGeometry.ClipPolygons(polygonsList);
            var pointList    = pathList.SelectMany(path => path, (path, point) => new Vector2(point.X, point.Y)).Where(currentPoint => !currentPoint.IsWall()).ToList();

            return(pointList);
        }