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); } }
public void Update(TimeSpan elapsedTime) { TimeAlmostOut = false; m_Period = MAX_PERIOD; //if (timeToDeath.Seconds <= OSCILLATE_START) //{ // m_Period = (int)(timeToDeath.TotalSeconds / OSCILLATE_START * (MAX_PERIOD - MIN_PERIOD)) + MIN_PERIOD; //} if (TimeToDeath.TotalSeconds <= OSCILLATE_START) { TimeAlmostOut = true; } if (BackGroundHueCounter >= m_Period + 1) { BackGroundHueCounter = 0; } if (TimeAlmostOut) { m_Period = MIN_PERIOD; } int delta = (int)(Math.Sin(BackGroundHueCounter * 2 * Math.PI / m_Period) * (SCALE / 2) + (SCALE / 2)); ++BackGroundHueCounter; BackGroundHueColor = new Color(255 - delta, delta, 0); for (int i = 0; i < ActiveGibs.Count; ++i) { ExplodedPart part = ActiveGibs[i]; bool hasStopped; part.Update(out hasStopped); if (hasStopped) { BakedGibs.Add(part); ActiveGibs.Remove(part); i--; } } }