public GameShip(ShipTemplate template) { this.Name = template.Name; this.Graphic = SpriteManager.GetGraphic(template.EntityTexture); this.LinearAcceleration = template.LinearAcceleration; this.LinearVelocityMax = template.LinearVelocityMax; this.AngularAcceleration = template.AngularAcceleration; this.AngularVelocityMax = template.AngularVelocityMax; this.StructureMax = template.Structure; this.Drops = new DropDefinition(template.DropCurrencyBase, template.DropExperienceBase); this.SignatureRadius = new BoundingCircle(this, template.SignatureRadius); this.Roles = (ShipRole)template.Roles; this.ShieldMax = template.Shield; this.HeatLimit = template.HeatLimit; this.ShieldRecoveryRate = template.ShieldRecoveryRate; this.HeatDegenerationRate = template.HeatDegenerationRate; this.Radar = new Radar(this, template.RadarRadius); this.Collider = new PolygonCollider(this, template.ColliderEdges); //this.NormalAttack = SkillManager.GetNormal(this, template.NormalAttackId); //this.Skills = new GameSkill[4]; this.Items = new GameItem[template.ItemSlotCount]; }
public bool Intersects(PolygonCollider p2, out Vector2 intersectionCenter, bool findAll = false) { Vector2 sp1, ep1, sp2, ep2; Vector2 intersectionPosition; intersectionCenter = new Vector2(float.NaN, float.NaN); List<Vector2> ipList = new List<Vector2>(); bool intersects = false; for (int i = 0; i < Edges.Length; i++) { sp1 = Edges[i]; ep1 = Edges[(i + 1) % Edges.Length]; for (int j = 0; j < p2.Edges.Length; j++) { sp2 = p2.Edges[j]; ep2 = p2.Edges[(j + 1) % p2.Edges.Length]; if (LineIntersection(sp1, ep1, sp2, ep2, out intersectionPosition)) { ipList.Add(intersectionPosition); if (!findAll) { intersectionCenter = intersectionPosition; return true; } intersects = true; } } } if (intersects && ipList.Count > 1) { intersectionCenter = GetIntersectionCenter(ipList); } return intersects; }