Time for action – the ExplosionManager class
Add a new class called "ExplosionManager" to the Asteroid Belt Assault project.
Add the standard
using
directives to the class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Add declarations to the ExplosionManager class:
private Texture2D texture; private List<Rectangle> pieceRectangles = new List<Rectangle>(); private Rectangle pointRectangle; private int minPieceCount = 3; private int maxPieceCount = 6; private int minPointCount = 20; private int maxPointCount = 30; private int durationCount = 90; private float explosionMaxSpeed = 30f; private float pieceSpeedScale = 6f; private int pointSpeedMin = 15; private int pointSpeedMax = 30; private Color initialColor = new Color(1.0f, 0.3f, 0f) * 0.5f; private Color finalColor = new Color(0f, 0f, 0f, 0f); Random rand = new Random(); private List<Particle> ExplosionParticles = new List<Particle>();
Add a constructor to the ExplosionManager class...