// Spawns x particles at the location to form an explosion // todo: refactor into explosion particle class public void AddExplosion(Vector2 location, Vector2 momentum) { switch (Type) { case ParticleType.Point: { int pointsToGenerate = _rand.Next(MinPointCount, MaxPointCount + 1); GeneratePoints(location, momentum, pointsToGenerate); break; } case ParticleType.Piece: { // location is the center of the sprite where we want to render the particle // so we compensate by calculating the upper left corner which is where we // need to position the particle for rendering Rectangle rect = _tileSheet.TileAt(0, 0); Vector2 pieceLocation = location - new Vector2(rect.Width / 2, rect.Height / 2); int piecesToGenerate = _rand.Next(MinPieceCount, MaxPieceCount + 1); GeneratePieces(pieceLocation, momentum, piecesToGenerate); break; } default: break; } }