Time for action – ShotManager-part 1
To manage the shots fired at each other by the tanks, we will add a ShotManager
class
by performing the following steps:
1. Add a new class file called
ShotManager.cs
to theTank Battles
project.2. Add the following declarations at the beginning of the
ShotManager
class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Modify the declaration of the class to make it a static class. The class definition line should now read as follows:
static class ShotManager
4. Add fields to the
Sho
tManager
class as follows:#region Fields public static Model ShotModel; public static Vector3 Position; public static Vector3 Velocity; public static Vector3 Gravity = new Vector3(0, -20, 0); public static bool ShotActive = false; public static bool HitProcessed = true; public static Terrain Terrain; private static float modelScale = 0.2f; #endregion
5. Add a method to fire shots to the
ShotManager
class as follows:#region Shot Handling public static...