예제 #1
0
        //private BrainMapMarker currentMapMarker = null;
        public BrainMapManager(SpriteBatch spriteBatch, Soul game, AudioManager audioManager, InputManager controls, Vector2 position)
        {
            this.audioManager = audioManager;
            bg = new Sprite(spriteBatch, game, Constants.BRAIN_MAP_BG);
            mapList = new List<BrainMapMarker>();

            List<BrainMapMarker> tmpList = new List<BrainMapMarker>();
            /*mapList.Add(tmpList);
            tmpList = new List<BrainMapMarker>();
            mapList.Add(tmpList);
            tmpList = new List<BrainMapMarker>();
            mapList.Add(tmpList);*/

            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 + 200), Constants.GUI_CLEANSE, "cleanse");
            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 + 200), Constants.GUI_BACK, "back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            fadeinOut = new FadeInOut(spriteBatch, game, 100);
            this.position = position;
            offset = new Vector2((float)bg.X * 0.5f, (float)bg.Y *0.5f);
            this.controls = controls;
        }
예제 #2
0
파일: MenuState.cs 프로젝트: rodstrom/soul
        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();
        }
예제 #3
0
        public void Initialize()
        {
            // Creating main menu
            MenuManager menuManager = new MenuManager(inputManager, "MainMenu");
            ImageButton button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_START, "start");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_OPTIONS, "options");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_CREDITS, "credits");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_QUIT, "quit");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["MainMenu"] = menuManager;

            // Creating options menu
            menuManager = new MenuManager(inputManager, "Options");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), Constants.GUI_GAME_PLAY, "gameplay");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_GRAPHICS, "graphics");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_SOUND, "sound");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_CONTROLS, "controls");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Options"] = menuManager;

            // Creating Sound Options Menu
            menuManager = new MenuManager(inputManager, "Sound");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_EFFECTS_VOLUME, "effect_volume");
            VolumeSlider volumeSlider = new VolumeSlider(spriteBatch, game, audioManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "effect_volume_slider");
            menuManager.AddButton(button, volumeSlider);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_MUSIC_VOLUME, "music_volume");
            volumeSlider = new VolumeSlider(spriteBatch, game, null, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "music_volume_slider");
            menuManager.AddButton(button, volumeSlider);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_BACK, "sound_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Sound"] = menuManager;

            // Creating Game Play Options Menu
            menuManager = new MenuManager(inputManager, "GamePlay");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_TUTORIAL, "tutorial");
            Selection selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "tutorial_selection");
            selection.AddSelection("On", Constants.GUI_ON);
            selection.AddSelection("Off", Constants.GUI_OFF);
            menuManager.AddButton(button, selection);
            bool tut = bool.Parse(game.config.getValue("General", "Tutorial"));
            if (tut == true)
            {
                selection.Selection = "On";
            }
            else
            {
                selection.Selection = "Off";
            }

            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_BACK, "game_play_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["GamePlay"] = menuManager;

            // Creating Graphics Options Menu
            menuManager = new MenuManager(inputManager, "Graphics");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_SPECULAR, "specular");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "specular_selection");
            selection.AddSelection("High", Constants.GUI_HIGH);
            selection.AddSelection("Medium", Constants.GUI_MEDIUM);
            selection.AddSelection("Low", Constants.GUI_LOW);
            selection.AddSelection("Off", Constants.GUI_OFF);
            float specular = float.Parse(game.config.getValue("Video", "Specular"));
            selection.Selection = ParseSpecularConfig(specular);
            menuManager.AddButton(button, selection);

            /*button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DYNAMIC_LIGHTING, "dynamic_lighting");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "dynamic_lighting_selection");
            selection.AddSelection("On", Constants.GUI_ON);
            selection.AddSelection("Off", Constants.GUI_OFF);
            bool dynLights = bool.Parse(game.config.getValue("Video", "DynamicLights"));
            if (dynLights == true)
            {
                selection.Selection = "On";
            }
            else
            {
                selection.Selection = "Off";
            }

            menuManager.AddButton(button, selection);*/

            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_SCREEN_MODE, "screen_mode");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "screen_mode_selection");
            selection.AddSelection("Fullscreen", Constants.GUI_FULLSCREEN);
            selection.AddSelection("Windowed", Constants.GUI_WINDOWED);

            if (bool.Parse(game.config.getValue("Video", "Fullscreen")) == true)
            {
                selection.Selection = "Fullscreen";
            }
            else
            {
                selection.Selection = "Windowed";
            }

            menuManager.AddButton(button, selection);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_RESOLUTION, "resolution");
            string output = game.Window.ClientBounds.Width + "x" + game.Window.ClientBounds.Height.ToString();
            Label label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), "resolution_label", output);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "graphics_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Graphics"] = menuManager;

            // Creating Controls Options Menu
            menuManager = new MenuManager(inputManager, "Controls");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), Constants.GUI_SHOOT, "controls_shoot");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), "shoot_string", inputManager.shoot.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_UP, "controls_up");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "up_string", inputManager.up.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DOWN, "controls_down");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "down_string", inputManager.down.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_LEFT, "controls_left");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), "left_string", inputManager.left.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_RIGHT, "controls_right");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), "right_string", inputManager.right.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 300.0f), Constants.GUI_BACK, "controls_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Controls"] = menuManager;

            // Creating Credits Options Menu
            menuManager = new MenuManager(inputManager, "Credits");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "credits_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            MenuImage menuImage = new MenuImage(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DEVELOPERS_CREDITS, "dev_text");
            menuManager.AddButton(button, menuImage);
            menuManager.initialize();
            menu["Credits"] = menuManager;

            // Creating Quit Menu
            menuManager = new MenuManager(inputManager, "Quit");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 200, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_YES, "quit_yes");
            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(OnButtonPress);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 200, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_NO, "quit_no");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Quit"] = menuManager;

            currentMenuManager = menu["MainMenu"];
            currentMenuManager.FadeIn();

            keyChangeWarning = new Vector2(game.Window.ClientBounds.Width * 0.5f, game.Window.ClientBounds.Height * 0.5f);
            spriteFont = game.Content.Load<SpriteFont>(Constants.GUI_FONT);
        }
예제 #4
0
파일: Level.cs 프로젝트: rodstrom/soul
        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);
        }