public override void ExplodeEnemy(Vector2 intersectingAngle, IEnemy enemy, Vector2 pos) { List <Texture2D> gibTextures = enemy.GetExplodedParts(); for (int i = 0; i < gibTextures.Count; ++i) { float randomTorque = (-1 + (Weapon.WEAPON_RANDOM.Next(2) * 2)) * (500000 + (500000f * (float)Weapon.WEAPON_RANDOM.NextDouble())); float randomDegree = -45f + (90f * (float)Weapon.WEAPON_RANDOM.NextDouble()); float randomForce = Knockback + (1500f * (float)Weapon.WEAPON_RANDOM.NextDouble()); ExplodedPart gib = new ExplodedPart(); gib.LoadContent(gibTextures[i], pos); //so we dont divide by zero if (intersectingAngle.X == 0) { intersectingAngle.X += 0.000001f; } float originalDegrees = (float)Math.Atan2(intersectingAngle.Y, intersectingAngle.X); float newDegrees = Utilities.NormalizeRadians(originalDegrees) + Utilities.DegreesToRadians(randomDegree); Vector2 change = new Vector2((float)Math.Cos(newDegrees), (float)Math.Sin(newDegrees)); gib.ApplyLinearForce(change, randomForce); //should be randomixed gib.ApplyTorque(randomTorque); UI.ActiveGibs.Add(gib); } }
public override void ExplodeEnemy(Vector2 intersectingAngle, IEnemy enemy, Vector2 pos) { List <Texture2D> gibTextures = enemy.GetExplodedParts(); float spreadAngle = 180; float singleAngle = (spreadAngle / (float)gibTextures.Count); float startingPoint = singleAngle * gibTextures.Count / 2; for (int i = 0; i < gibTextures.Count; ++i) { ExplodedPart gib = new ExplodedPart(); gib.LoadContent(gibTextures[i], pos); Vector2 halfAngle = Utilities.RadiansToVector2(Utilities.DegreesToRadians(-30)); gib.ApplyLinearForce(intersectingAngle - (halfAngle) + (i * 2 * halfAngle), Knockback); //should be randomixed gib.ApplyTorque(5000f); UI.ActiveGibs.Add(gib); } }