Exemple #1
0
 private void DarkenScreen()
 {
     if (playerNightmareHit == false && playerHit == false)
     {
         currentAmbientFade = NightmareAmbientFade;
         currentAmbientFade.Reset();
         currentAmbientFade.SetCurrentColor(ambientLight);
         currentAmbientFade.SetTargetColor(levelAmbient);
     }
     playerNightmareHit = true;
 }
Exemple #2
0
        private void PlayerHitFlash()
        {
            if (playerHit == false)
            {
                currentAmbientFade = PlayerHitAmbientFade;
                currentAmbientFade.Reset();
                currentAmbientFade.SetCurrentColor(ambientLight);
                currentAmbientFade.SetTargetColor(NightmareAmbientFade.CurrentColor);
            }

            playerHit = true;
        }
Exemple #3
0
        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);
        }