Time for action – beginning the WeaponManager class
Add a new class called WeaponManager to the Robot Rampage project.
Add the following
using
directives to the top of the WeaponManager class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Modify the declaration of the WeaponManager class to make it a static class:
static class WeaponManager
Add declarations to the WeaponManager class:
#region declarations static public List<Particle> Shots = new List<Particle>(); static public Texture2D Texture; static public Rectangle shotRectangle = new Rectangle(0, 128, 32, 32); static public float WeaponSpeed = 600f; static private float shotTimer = 0f; static private float shotMinTimer = 0.15f; #endregion
Add properties to the WeaponManager class:
#region Properties static public float WeaponFireDelay { get { return shotMinTimer; } } static public bool CanFireWeapon { get { return (shotTimer >= WeaponFireDelay); ...