Time for action – creating the CollisionManager class
Add a new class called CollisionManager to the AsteroidBeltAssault class.
Add the following
using
directive to the top of the class:using Microsoft.Xna.Framework;
Add declarations to the CollisionManager class:
private AsteroidManager asteroidManager; private PlayerManager playerManager; private EnemyManager enemyManager; private ExplosionManager explosionManager; private Vector2 offScreen = new Vector2(-500, -500); private Vector2 shotToAsteroidImpact = new Vector2(0, -20); private int enemyPointValue = 100;
Add a constructor to the CollisionManager class:
public CollisionManager( AsteroidManager asteroidManager, PlayerManager playerManager, EnemyManager enemyManager, ExplosionManager explosionManager) { this.asteroidManager = asteroidManager; this.playerManager = playerManager; this.enemyManager = enemyManager; this.explosionManager = explosionManager; }
What just happened?
Since the CollisionManager will...