Esempio n. 1
0
        public Game1()
        {
            //General XNA setup
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;

            //Enumerate the available display modes
            // graphicsadapter has supporteddisplaymodes

            GraphicsAdapter gdi = GraphicsAdapter.DefaultAdapter;
            AvailableModes = gdi.SupportedDisplayModes;

            ModeList = new List<DisplayMode>();
            foreach (DisplayMode d in AvailableModes)
            {
                ModeList.Add(d);
            }

            //((DisplayMode)Modes[0]).Width

            //Load configuration
            Stage = StageManager.CreateFromConfigFile("monstermaze.config");
            graphics.PreferredBackBufferWidth = Stage.ConfigurationSettings.width;
            graphics.PreferredBackBufferHeight = Stage.ConfigurationSettings.Height;

            //graphics.PreferredBackBufferWidth = 1600;
            //graphics.PreferredBackBufferHeight = 1200;

            graphics.IsFullScreen = Stage.ConfigurationSettings.Fullscreen;

            OptionsFullscreen = Stage.ConfigurationSettings.Fullscreen;
            OptionsDisplayModeHeight = Stage.ConfigurationSettings.Height;
            OptionsDisplayModeWidth = Stage.ConfigurationSettings.width;

            try
            {
                //Load the extra config file.
                ExtraConfigFile = ExtraConfig.LoadFromFile("CCExtra.config");
            }
            catch
            {
                //If the extra config file isn't found (or can't be loaded) create a new one with default settings and save that.
                ExtraConfigFile = new ExtraConfig();
                ExtraConfigFile.ExtraBoolSettings = new Dictionary<string, bool>();
                ExtraConfigFile.ExtraFloatSettings = new Dictionary<string, float>();
                ExtraConfigFile.SaveTofile("CCExtra.config");
            }

            //floats
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("ViewDistance"))
                ExtraConfigFile.ExtraFloatSettings["ViewDistance"] = 50.0f;
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("SoundVolume"))
                ExtraConfigFile.ExtraFloatSettings["SoundVolume"] = 50.0f;
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("MusicVolume"))
                ExtraConfigFile.ExtraFloatSettings["MusicVolume"] = 40.0f;
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("BloomLevel"))
                ExtraConfigFile.ExtraFloatSettings["BloomLevel"] = 50.0f;
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("ParticleDensity"))
                ExtraConfigFile.ExtraFloatSettings["ParticleDensity"] = 100.0f;
            if (!ExtraConfigFile.ExtraFloatSettings.Keys.Contains("TextureSampler"))
                ExtraConfigFile.ExtraFloatSettings["TextureSampler"] = 99.0f;

            OptionsBloomLevel = ExtraConfigFile.ExtraFloatSettings["BloomLevel"];
            OptionsParticleDensity = ExtraConfigFile.ExtraFloatSettings["ParticleDensity"];
            OptionsSFXVolume = ExtraConfigFile.ExtraFloatSettings["SoundVolume"];
            OptionsTextureSampler = ExtraConfigFile.ExtraFloatSettings["TextureSampler"];
            OptionsViewDistance = ExtraConfigFile.ExtraFloatSettings["ViewDistance"];
            OptionsMusicVolume = ExtraConfigFile.ExtraFloatSettings["MusicVolume"];

            //bools
            if (!ExtraConfigFile.ExtraBoolSettings.Keys.Contains("BloomOn"))
                ExtraConfigFile.ExtraBoolSettings["BloomOn"] = true;
            if (!ExtraConfigFile.ExtraBoolSettings.Keys.Contains("SFXMute"))
                ExtraConfigFile.ExtraBoolSettings["SFXMute"] = false;
            if (!ExtraConfigFile.ExtraBoolSettings.Keys.Contains("MusicMute"))
                ExtraConfigFile.ExtraBoolSettings["MusicMute"] = false;

            OptionsBloomOn = ExtraConfigFile.ExtraBoolSettings["BloomOn"];
            OptionsMuteMusic = ExtraConfigFile.ExtraBoolSettings["MusicMute"];
            OptionsMuteSFX = ExtraConfigFile.ExtraBoolSettings["SFXMute"];

            graphics.PreferredDepthStencilFormat = DepthFormat.Depth32;

            random = new Random();
            for(int i=0;i<10;i++)
                random.Next(1,1000);

            //Particles
            #region Particle system test
            // Construct our particle system components.
            //explosionParticles = new ExplosionParticleSystem(this, Content);
            //explosionSmokeParticles = new ExplosionSmokeParticleSystem(this, Content);
            //projectileTrailParticles = new ProjectileTrailParticleSystem(this, Content);
            smokePlumeParticles = new SmokePlumeParticleSystem(this, Content,(int)OptionsParticleDensity);
            fireParticles = new FireParticleSystem(this, Content, (int)OptionsParticleDensity);
            antifireParticles = new AntiFireParticleSystem(this, Content, (int)OptionsParticleDensity);

            // Set the draw order so the explosions and fire
            // will appear over the top of the smoke.
            //smokePlumeParticles.DrawOrder =
            //explosionSmokeParticles.DrawOrder = 200;
            //projectileTrailParticles.DrawOrder = 300;
            //explosionParticles.DrawOrder = 400;
            //fireParticles.DrawOrder = 500;

            // Register the particle system components.
            //Components.Add(explosionParticles);
            //Components.Add(explosionSmokeParticles);
            //Components.Add(projectileTrailParticles);
            //Components.Add(smokePlumeParticles);
            //Components.Add(fireParticles);
            #endregion

            //Bloom
            bloom = new BloomComponent(this);
            bloom.Settings = BloomSettings.PresetSettings[bloomSettingsIndex];
            bloom.FadeSettings = new PostFadeSettings();

            //Components.Add(bloom);

            bloom.Settings.BloomIntensity = 3.0f * (OptionsBloomLevel / 100);
        }
Esempio n. 2
0
 /// <summary>
 /// Create a new instance of stage manager with config,
 /// default level and default map specified by a config file.
 /// </summary>
 /// <param name="filename">The name of the config file</param>
 /// <returns>A new stage manager object</returns>
 public static StageManager CreateFromConfigFile(string filename)
 {
     StageManager sm = new StageManager();
     sm.LoadConfigFromFile(filename);
     return sm;
 }
Esempio n. 3
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Game1()
        {
            //General XNA setup
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;

            //Load configuration
            Stage = StageManager.CreateFromConfigFile("bane.config");
            graphics.PreferredBackBufferWidth = Stage.ConfigurationSettings.width;
            graphics.PreferredBackBufferHeight = Stage.ConfigurationSettings.Height;
            graphics.IsFullScreen = Stage.ConfigurationSettings.Fullscreen;
        }