Ejemplo n.º 1
0
        public static M_Polygon GetCircleClosed(Vector2 pos, float radius, int vertices)
        {
            M_Polygon poly = GetCircleOpen(pos, radius, vertices - 1);

            poly.vertices.Add(poly.vertices[0]);
            return(poly);
        }
Ejemplo n.º 2
0
 public override CollisionResult DistToPolygon(M_Polygon polygon, Vector2 dir)
 {
     //if (Input.rightShift.down)
     //    return Collision.DistPolygonPolygon2(this, polygon, dir);
     //else
     return(Collision.DistPolygonPolygon(this, polygon, dir));
 }
Ejemplo n.º 3
0
        public override Mask Clone()
        {
            M_Polygon clone = (M_Polygon)this.MemberwiseClone();

            clone.vertices = vertices.ToList();
            return(clone);
        }
Ejemplo n.º 4
0
 public override CollisionResult DistToPolygon(M_Polygon polygon)
 {
     return(new CollisionResult()
     {
         collision = masks.Any(f => f.ColPolygon(polygon))
     });
     //return MaxCol(f => f.DistToPolygon(polygon));
 }
Ejemplo n.º 5
0
        public static M_Polygon GetCircleOpen(Vector2 pos, float radius, int vertices)
        {
            M_Polygon poly = new M_Polygon(pos, new List <Vector2>());

            for (int i = 0; i < vertices; i++)
            {
                float a = i * MathHelper.TwoPi / vertices;
                poly.vertices.Add(new Vector2((float)Math.Cos(a) * radius, (float)Math.Sin(a) * radius));
            }
            return(poly);
        }
Ejemplo n.º 6
0
        public static M_Polygon GetRandomConvex(Vector2 pos, Random rand, float radius, float angleMin, float angleRange)
        {
            M_Polygon poly = new M_Polygon(pos, new List <Vector2>());

            float startAngle = (float)rand.NextDouble() * MathHelper.TwoPi;

            for (float a = 0f; a < MathHelper.TwoPi;)          // full circle
            {
                poly.vertices.Add(new Vector2((float)Math.Cos(startAngle + a) * radius, (float)Math.Sin(startAngle + a) * radius));
                a += (float)((angleMin + (angleRange * rand.NextDouble())) * Math.PI / 180f);
            }

            return(poly);
        }
Ejemplo n.º 7
0
        public static M_Polygon GetCirclePart(Vector2 pos, float radius, float angle, float fov, int vertices)
        {
            M_Polygon poly = new M_Polygon(pos, new List <Vector2>()
            {
                Vector2.Zero
            });
            float a    = angle - fov / 2f;
            float plus = fov / (vertices - 1);

            for (int i = 0; i < vertices; i++)
            {
                poly.vertices.Add(new Vector2((float)Math.Cos(a) * radius, (float)Math.Sin(a) * radius));
                a += plus;
            }
            return(poly);
        }
Ejemplo n.º 8
0
 public abstract CollisionResult DistToPolygon(M_Polygon polygon, Vector2 dir);
Ejemplo n.º 9
0
 public override CollisionResult DistToPolygon(M_Polygon polygon, Vector2 dir)
 {
     return(MinCol(f => f.DistToPolygon(polygon, dir)));
 }
Ejemplo n.º 10
0
 public override bool ColPolygon(M_Polygon polygon)
 {
     return(masks.Any(f => f.ColPolygon(polygon)));
 }
Ejemplo n.º 11
0
 public override CollisionResult DistToPolygon(M_Polygon polygon)
 {
     return(Collision.DistPolygonCircle(polygon, this).GetAxisInvert());
 }
Ejemplo n.º 12
0
 public override bool ColPolygon(M_Polygon polygon)
 {
     return(Collision.ColPolygonCircle(polygon, this));
 }
Ejemplo n.º 13
0
 public override CollisionResult DistToPolygon(M_Polygon polygon)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public override CollisionResult DistToPolygon(M_Polygon polygon)
 {
     return(Collision.DistVectorPolygon(pos, polygon));
 }
Ejemplo n.º 15
0
 public override bool ColPolygon(M_Polygon polygon)
 {
     return(Collision.ColVectorPolygon(pos, polygon));
 }
Ejemplo n.º 16
0
 public abstract CollisionResult DistToPolygon(M_Polygon polygon);
Ejemplo n.º 17
0
 public abstract bool ColPolygon(M_Polygon polygon);
Ejemplo n.º 18
0
 public override CollisionResult DistToPolygon(M_Polygon polygon)
 {
     return(Collision.DistPolygonPolygon(this, polygon));
 }
Ejemplo n.º 19
0
 public override bool ColPolygon(M_Polygon polygon)
 {
     return(Collision.ColPolygonPolygon(this, polygon));
 }