protected override bool TestPoly(PolyCollider c) { List <Vector2> Normals = new List <Vector2> (); Vector2 Projection; Vector2 CProjection; Normals.Add((Parent.Points [1] - Parent.Points [0]).PerpendicularLeft.Normalized()); Normals.Add((Parent.Points [2] - Parent.Points [1]).PerpendicularLeft.Normalized()); for (int i = 1; i < c.Parent.Points.Count; i++) { Vector2 Point2 = c.Parent.Points [i]; Vector2 Point1 = c.Parent.Points [i - 1]; Normals.Add((Point2 - Point1).PerpendicularLeft.Normalized()); } for (int i = 0; i < Normals.Count; i++) { CProjection = Collider.ProjectCollider(Normals [i], c.Parent.Points); Projection = Collider.ProjectCollider(Normals [i], Parent.Points); if (CProjection.Y < Projection.X || CProjection.X > Projection.Y) { return(false); } } return(true); }
public Polygon(Color Colour, bool Visible, List <Vector2> Points) : base(Colour, Visible) { this.Points = Points; Shape.AllShapes.Add(this); Coll = new PolyCollider(this); Body = new Rigidbody(this); }
protected abstract bool TestPoly(PolyCollider c);