I have a similar issue concerning the rate of fire. This is the code I use to determine how often an enemy shoots:
float thrustTimer;
float lastthrustTimer;
float thrustTimeSpan = 3.0f; //declerations
thrustTimer = thrustTimeSpan; //initialization
thrustTimer -= (float)gameTime.ElapsedRealTime.TotalSeconds; //update
if ((thrustTimer - lastthrustTimer) < 0.0f)
{
if (thrustTimer < (thrustTimeSpan - 1.0f) && thrustTimer > 0.0f)
RocketShot(rocketList, enemyship);
}
lastthrustTimer = (int)thrustTimer;
This triggers the rocket shot between each second but it makes it too difficult for the player to shoot back so I want it to be between each 2 second interval, does anyone know how to do this? I got this method from the SpaceWar game so I don't really know how it works.