private void QuitConfirm(ImageButton button) { if (button.ID == "quit_yes") { fade.FadeOut(); quit = true; } else if (button.ID == "quit_no") { askToQuit.FadeOut(); //menuStateManager.FadeInMenu(); } }
private void OnButtonPress(ImageButton button) { if (button.ID == "continue") { pause = false; menuManager.FadeOut(); audioManager.playSound("menu_select"); } else if (button.ID == "quit") { quit = true; menuManager.FadeOut(); audioManager.playSound("menu_select"); } }
public override void initialize(string data) { this.pressStartOnce = false; glowList = new List<GlowParticle>(); nextState = ""; bg = new Sprite(spriteBatch, game, Constants.MENU_COMBINED_BG_COLORMAP); bg_normal = new Sprite(spriteBatch, game, Constants.MENU_COMBINED_BG_NORMALMAP); bg_front = new Sprite(spriteBatch, game, Constants.MENU_FRONT_BG_COLORMAP); bg_front_normal = new Sprite(spriteBatch, game, Constants.MENU_FRONT_BG_NORMALMAP); bg_spikes = new Sprite(spriteBatch, game, Constants.MENU_SPIKES_BG_COLORMAP); fog = new Sprite(spriteBatch, game, "Backgrounds\\background__0002s_0001_Layer-8"); logo = new Sprite(spriteBatch, game, "GUI\\logo_SOUL"); fade = new FadeInOut(spriteBatch, game); audio.playMusic("menu_music"); glowFX = new GlowFX(game); menuStateManager = new MenuStateManager(spriteBatch, game, graphics, displayModes, controls, audio); menuStateManager.Initialize(); spriteFont = game.Content.Load<SpriteFont>(Constants.GUI_FONT); askToQuit = new MenuManager(controls, "askToQuit"); ImageButton button = new ImageButton(spriteBatch, game, controls, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 300, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_YES, "quit_yes"); Label label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f), "quit_text", "Are you sure you want to quit?", false); button.onClick += new ImageButton.ButtonEventHandler(QuitConfirm); askToQuit.AddButton(button, label); button = new ImageButton(spriteBatch, game, controls, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_NO, "quit_no"); button.onClick += new ImageButton.ButtonEventHandler(QuitConfirm); askToQuit.AddButton(button); askToQuit.initialize(); #region InitializeLighting PresentationParameters pp = game.GraphicsDevice.PresentationParameters; //int width = Constants.RESOLUTION_VIRTUAL_WIDTH; //int height = Constants.RESOLUTION_VIRTUAL_HEIGHT; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; SurfaceFormat format = pp.BackBufferFormat; Vertices = new VertexPositionColorTexture[4]; Vertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0)); Vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0)); Vertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1)); Vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1)); VertexBuffer = new VertexBuffer(game.GraphicsDevice, typeof(VertexPositionColorTexture), Vertices.Length, BufferUsage.None); VertexBuffer.SetData(Vertices); colorMap = new RenderTarget2D(game.GraphicsDevice, width, height); normalMap = new RenderTarget2D(game.GraphicsDevice, width, height); shadowMap = new RenderTarget2D(game.GraphicsDevice, width, height, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); lightEffect = game.Content.Load<Effect>("Shaders\\MultiTarget"); lightCombinedEffect = game.Content.Load<Effect>("Shaders\\DeferredCombined"); lightEffectTechniquePointLight = lightEffect.Techniques["DeferredPointLight"]; lightEffectParameterConeDirection = lightEffect.Parameters["coneDirection"]; lightEffectParameterLightColor = lightEffect.Parameters["lightColor"]; lightEffectParameterLightDecay = lightEffect.Parameters["lightDecay"]; lightEffectParameterNormalMap = lightEffect.Parameters["NormalMap"]; lightEffectParameterPosition = lightEffect.Parameters["lightPosition"]; lightEffectParameterScreenHeight = lightEffect.Parameters["screenHeight"]; lightEffectParameterScreenWidth = lightEffect.Parameters["screenWidth"]; lightEffectParameterStrenght = lightEffect.Parameters["lightStrength"]; lightCombinedEffectTechnique = lightCombinedEffect.Techniques["DeferredCombined2"]; lightCombinedEffectParamAmbient = lightCombinedEffect.Parameters["ambient"]; lightCombinedEffectParamLightAmbient = lightCombinedEffect.Parameters["lightAmbient"]; lightCombinedEffectParamAmbientColor = lightCombinedEffect.Parameters["ambientColor"]; lightCombinedEffectParamColorMap = lightCombinedEffect.Parameters["ColorMap"]; lightCombinedEffectParamShadowMap = lightCombinedEffect.Parameters["ShadingMap"]; lightCombinedEffectParamNormalMap = lightCombinedEffect.Parameters["NormalMap"]; #endregion InitializeLighting /*PointLight light = new PointLight() { Color = new Vector4(1f, 1f, 1f, 1f), Power = 8f, LightDecay = 300, Position = new Vector3(200f, 400f, 50f), IsEnabled = true }; lights.Add(light);*/ random = new Random(); fade.FadeIn(); }
public void initialize() { if (id == "level01") { game.constants = new IniFile("Content\\Config\\constants_level01.ini"); game.constants.parse(); game.lighting = new IniFile("Content\\Config\\lighting_level01.ini"); game.lighting.parse(); } else if (id == "level02") { game.constants = new IniFile("Content\\Config\\constants_level02.ini"); game.constants.parse(); game.lighting = new IniFile("Content\\Config\\lighting_level02.ini"); game.lighting.parse(); } else if (id == "level03") { game.constants = new IniFile("Content\\Config\\constants_level03.ini"); game.constants.parse(); game.lighting = new IniFile("Content\\Config\\lighting_level03.ini"); game.lighting.parse(); } this.lightGenerator = new LightGenerator(game, lights); this.stopRandomLights = false; levelAmbient = new Color(byte.Parse(game.lighting.getValue("AmbientLight", "ColorR")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorG")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorB")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorA"))); ambientLight = new Color(byte.Parse(game.lighting.getValue("AmbientLight", "ColorR")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorG")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorB")), byte.Parse(game.lighting.getValue("AmbientLight", "ColorA"))); levelReader.Parse(); entityManager.AddEntityDataList(levelReader.EntityDataList); entityManager.AddLightList(lights); entityManager.initialize(); CreateBackgrounds(); menuManager = new MenuManager(controls); ImageButton button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f), Constants.GUI_CONTINUE, "continue"); button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress); menuManager.AddButton(button); button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f), Constants.GUI_QUIT, "quit"); button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress); menuManager.AddButton(button); menuManager.initialize(); PresentationParameters pp = game.GraphicsDevice.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; SurfaceFormat format = pp.BackBufferFormat; Vertices = new VertexPositionColorTexture[4]; Vertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0)); Vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0)); Vertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1)); Vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1)); VertexBuffer = new VertexBuffer(game.GraphicsDevice, typeof(VertexPositionColorTexture), Vertices.Length, BufferUsage.None); VertexBuffer.SetData(Vertices); colorMap_back = new RenderTarget2D(game.GraphicsDevice, width, height); normalMap_back = new RenderTarget2D(game.GraphicsDevice, width, height); shadowMap_back = new RenderTarget2D(game.GraphicsDevice, width, height, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); entityLayer = new RenderTarget2D(game.GraphicsDevice, width, height); colorMap_front = new RenderTarget2D(game.GraphicsDevice, width, height); normalMap_front = new RenderTarget2D(game.GraphicsDevice, width, height); shadowMap_front = new RenderTarget2D(game.GraphicsDevice, width, height, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); lightEffect = game.Content.Load<Effect>("Shaders\\MultiTarget"); lightCombinedEffect = game.Content.Load<Effect>("Shaders\\DeferredCombined"); lightEffectTechniquePointLight = lightEffect.Techniques["DeferredPointLight"]; lightEffectParameterConeDirection = lightEffect.Parameters["coneDirection"]; lightEffectParameterLightColor = lightEffect.Parameters["lightColor"]; lightEffectParameterLightDecay = lightEffect.Parameters["lightDecay"]; lightEffectParameterNormalMap = lightEffect.Parameters["NormalMap"]; lightEffectParameterPosition = lightEffect.Parameters["lightPosition"]; lightEffectParameterScreenHeight = lightEffect.Parameters["screenHeight"]; lightEffectParameterScreenWidth = lightEffect.Parameters["screenWidth"]; lightEffectParameterStrenght = lightEffect.Parameters["lightStrength"]; lightCombinedEffectTechnique = lightCombinedEffect.Techniques["DeferredCombined2"]; lightCombinedEffectParamAmbient = lightCombinedEffect.Parameters["ambient"]; lightCombinedEffectParamLightAmbient = lightCombinedEffect.Parameters["lightAmbient"]; lightCombinedEffectParamAmbientColor = lightCombinedEffect.Parameters["ambientColor"]; lightCombinedEffectParamColorMap = lightCombinedEffect.Parameters["ColorMap"]; lightCombinedEffectParamShadowMap = lightCombinedEffect.Parameters["ShadingMap"]; lightCombinedEffectParamNormalMap = lightCombinedEffect.Parameters["NormalMap"]; bg1 = new Sprite(spriteBatch, game, "Backgrounds\\background__0002s_0008_Layer-1_combined"); bg1_normal = new Sprite(spriteBatch, game, "Backgrounds\\background__0002s_0008_Layer-1_combined_depth"); fog = new Sprite(spriteBatch, game, Constants.BACKGROUND_FOG); fog_normal = new Sprite(spriteBatch, game, Constants.BACKGROUND_FOG_NORMAL); player.nightmareHit += new Player.NightmareHit(DarkenScreen); player.hitFlash += new Player.HitFlash(PlayerHitFlash); lights.Add(player.PointLight); lights.Add(player.HealthLight); specularStrenght = float.Parse(game.config.getValue("Video", "Specular")); useDynamicLights = bool.Parse(game.config.getValue("Video", "DynamicLights")); NightmareAmbientFade = new AmbientFade("NightmareAmbientFade", new Color(0, 0, 0, 255), 10, 2, float.Parse(game.constants.getValue("NIGHTMARE", "DARKNESS"))); NightmareAmbientFade.SetCurrentColor(ambientLight); PlayerHitAmbientFade = new AmbientFade("PlayerAmbientHit", new Color(byte.Parse(game.lighting.getValue("PlayerHitLight", "ColorR")), byte.Parse(game.lighting.getValue("PlayerHitLight", "ColorG")), byte.Parse(game.lighting.getValue("PlayerHitLight", "ColorB")), byte.Parse(game.lighting.getValue("PlayerHitLight", "ColorA"))), 15, 15); this.tutorial = bool.Parse(game.config.getValue("General", "Tutorial")); if (tutorial == true) { tutorialManager = new TutorialManager(spriteBatch, game, font, controls); tutorialManager.Initialize("movement"); } game.Content.Load<Texture2D>(Constants.BOSS_IDLE_FILENAME); game.Content.Load<Texture2D>(Constants.BOSS_SHOOT_FILENAME); game.Content.Load<Texture2D>(Constants.BOSS_SPAWN_FILENAME); game.Content.Load<Texture2D>(Constants.BOSS_DEATH_FILENAME); }