It seems to me that gun sounds in movies and games are very, very far from the way real gun shots actually sound, both live and recorded. Movie and game gun sound effects are typically very heavy in the low end, which gives the impression of "punch" and "force". There might be plenty of low frequency content in real gun shots, but to me, it sounds like they are completely dominated by transients in the mid to high frequency range. So in order to record great sound effects for games you might want to turn to other sources like fireworks or recordings of high caliber artillery.
In order to record "dry" sounds without a lot of ambient sound reflections, you might need special microphones that can cope with the sound pressure level (SPL) generated by firearms. According to this source, gunfire noise reaches 155+ dB. A sampling of the max. SPL of popular condenser microphones from Neumann, AKG and RODE seem to fall well below this level. The max. SPL rating of the Shure MK57 dynamic microphone is 150dB.
There are plenty of sound effect library CDs that offer various recordings of gun shots.
Regardless of where you obtain recordings of gun shots, fireworks, etc., I would expect to spend a fair amount of time post processing the sound with compressors, EQ, tube distortion, and other effects to find just the right timbre and expression to match the style of the game and the other sound effects.
There are people who make a living off making sound effects for games and movies; I am sure there's much more to the art of making sound effects than what I just outlined here. For example, the Wikipedia article I just linked to mention that:
heavy staple gun combined with other small metal sounds make good gun noises[
As for the gun sound changing character depending on the environment, you might want to consider achieving this using real-time DSP effects, provided you haven't completely used up the CPU load budget. Unless you create a huge number of fixed sample variations, you will be able to create much more realistic changes to the sound using simple reverb and echo effects in-game. The ear is extremely sensitive to changes in reverb, so you will need to keep track of a large number of fixed samples in order to create convincing transitions as the player moves around in the game's different environments. With real-time DSP you basically just need to adjust the decay time, delay time and dry/wet ratio of the reverb DSP in response to the player's position and the environment.