Example #1
0
        protected override void LoadContent()
        {
            // Load textures
            Texture2D backgroundTexture = Game.Content.Load <Texture2D>("Textures/solid225-tiling");

            // Load fonts
            SpriteFont menuFont2 = Game.Content.Load <SpriteFont>("Fonts/MenuFont2");

            // Create gui manager
            gui = new InterfaceManager(core);

            // Add a stack panel for menu items
            PanelScreenComponent panel = new PanelScreenComponent(core, Vector2.Zero, new Vector2(400, 200));

            panel.HorizontalAlignment     = HorizontalAlignment.Center;
            panel.VerticalAlignment       = VerticalAlignment.Middle;
            panel.BackgroundTexture       = backgroundTexture;
            panel.BackgroundTextureLayout = TextureLayout.Tile;
            panel.TopMargin    = 20;
            panel.LeftMargin   = 20;
            panel.RightMargin  = 20;
            panel.BottomMargin = 10;

            // Set panel borders
            panel.SetBorderTextures(
                Game.Content.Load <Texture2D>("Textures/top-left"),
                Game.Content.Load <Texture2D>("Textures/top"),
                Game.Content.Load <Texture2D>("Textures/top-right"),
                Game.Content.Load <Texture2D>("Textures/left"),
                Game.Content.Load <Texture2D>("Textures/right"),
                Game.Content.Load <Texture2D>("Textures/bottom-left"),
                Game.Content.Load <Texture2D>("Textures/bottom"),
                Game.Content.Load <Texture2D>("Textures/bottom-right"));
            panel.EnableBorder = true;

            // Add stack panel to gui
            gui.Components.Add(panel);

            // Exit game text
            TextItemScreenComponent exitGameText = new TextItemScreenComponent(core, menuFont2, "Exit Game?");

            exitGameText.HorizontalAlignment = HorizontalAlignment.Center;
            exitGameText.VerticalAlignment   = VerticalAlignment.Top;
            exitGameText.EnableOutline       = true;
            exitGameText.OutlineColor        = Color.Black;
            exitGameText.ShadowColor         = Color.Black;
            exitGameText.ShadowVector        = new Vector2(3, 3);

            // Continue button
            TextItemScreenComponent continueButton = new TextItemScreenComponent(core, menuFont2, "Back");

            continueButton.HorizontalAlignment = HorizontalAlignment.Left;
            continueButton.VerticalAlignment   = VerticalAlignment.Bottom;
            continueButton.EnableOutline       = false;
            continueButton.OutlineColor        = Color.Goldenrod;

            // Exit button
            TextItemScreenComponent exitButton = new TextItemScreenComponent(core, menuFont2, "Exit");

            exitButton.HorizontalAlignment = HorizontalAlignment.Right;
            exitButton.VerticalAlignment   = VerticalAlignment.Bottom;
            exitButton.EnableOutline       = false;
            exitButton.OutlineColor        = Color.Goldenrod;

            // Wire up events
            continueButton.OnMouseEnter += new EventHandler(OnMouseEnter);
            continueButton.OnMouseLeave += new EventHandler(OnMouseLeave);
            continueButton.OnMouseClick += new EventHandler(ContinueButton_OnMouseClick);
            exitButton.OnMouseEnter     += new EventHandler(OnMouseEnter);
            exitButton.OnMouseLeave     += new EventHandler(OnMouseLeave);
            exitButton.OnMouseClick     += new EventHandler(ExitButton_OnMouseClick);

            // Add items to stack panel
            panel.Components.Add(exitGameText);
            panel.Components.Add(exitButton);
            panel.Components.Add(continueButton);
        }
        protected override void LoadContent()
        {
            // Create scene
            scene = new Scene(core);
            scene.Camera.Position = new Vector3(33.0625f, 4.4375f, 89.8125f);
            scene.Camera.Transform(327, 0, Vector3.Zero);
            scene.Camera.Update();
            core.ActiveScene = scene;

            // Disable core input handling
            core.Input.ActiveDevices = Input.DeviceFlags.None;

            core.Renderer.ClearColor = clearColor;

            // Set day/night mode for window textures
            core.MaterialManager.Daytime = false;

            // Set climate
            DFLocation.ClimateSettings climateSettings = MapsFile.DefaultClimateSettings;
            climateSettings.ClimateType    = DFLocation.ClimateBaseType.Swamp;
            climateSettings.SceneryArchive = 510;

            // Create level entity
            DynamicEntity level = new DynamicEntity(core.ActiveScene);

            // Create block component
            DaggerfallBlockComponent block = new DaggerfallBlockComponent(core);

            block.LoadBlock("CASTAA26.RMB", climateSettings, core.ActiveScene, true);
            level.Components.Add(block);

            // Attach block flats
            AddBlockFlats(level, block);

            // Create directional lights
            Color         lightColor       = new Color(100, 100, 200);
            DynamicEntity directionalLight = new DynamicEntity(core.ActiveScene);

            directionalLight.Components.Add(new LightComponent(core, Vector3.Normalize(Vector3.Down + Vector3.Right), lightColor, 0.60f));
            directionalLight.Components.Add(new LightComponent(core, Vector3.Normalize(Vector3.Forward + Vector3.Left), lightColor, 0.90f));

            // Create fireflies in courtyard
            for (int i = 0; i < 10; i++)
            {
                Entities.Firefly firefly = new Entities.Firefly(scene);
                firefly.Matrix = Matrix.CreateTranslation(62.5f, 3.125f, 43.75f);
            }

            // Create fireflies in left of courtyard
            for (int i = 0; i < 10; i++)
            {
                Entities.Firefly firefly = new Entities.Firefly(scene);
                firefly.Matrix = Matrix.CreateTranslation(31.25f, 3.125f, 43.75f);
            }

            // Create fireflies near camera
            for (int i = 0; i < 10; i++)
            {
                Entities.Firefly firefly = new Entities.Firefly(scene);
                firefly.Matrix = Matrix.CreateTranslation(37.5f, 3.125f, 75f);
            }

            // Load songs
            song = Game.Content.Load <Song>("Songs/DanGoodale_DF-11");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(song);

            // Load fonts
            titleFont   = Game.Content.Load <SpriteFont>("Fonts/TitleFont");
            consoleFont = Game.Content.Load <SpriteFont>("Fonts/ConsoleFont");
            menuFont    = Game.Content.Load <SpriteFont>("Fonts/MenuFont");
            menuFont2   = Game.Content.Load <SpriteFont>("Fonts/MenuFont2");

            // Create gui manager
            gui = new InterfaceManager(core);
            gui.SetMargins(Margins.All, 20);

            // Create a stack panel
            StackPanelScreenComponent stackPanel = new StackPanelScreenComponent(core, Vector2.Zero, new Vector2(500, 300), 0);

            stackPanel.HorizontalAlignment = HorizontalAlignment.Right;
            gui.Components.Add(stackPanel);

            // Create title text
            TextItemScreenComponent title = new TextItemScreenComponent(core, titleFont, titleText, HorizontalAlignment.Right, VerticalAlignment.None);

            title.OutlineColor  = Color.Gray;
            title.EnableOutline = true;
            title.ShadowColor   = Color.MidnightBlue;
            title.ShadowVector  = new Vector2(3, 3);

            // Create version text
            TextItemScreenComponent version = new TextItemScreenComponent(core, consoleFont, versionText, HorizontalAlignment.Right, VerticalAlignment.None);

            version.TextColor = Color.Gold;

            // Create start menu item
            startMenuItem              = new TextItemScreenComponent(core, menuFont2, startMenuText, HorizontalAlignment.Right, VerticalAlignment.None);
            startMenuItem.TextColor    = Color.White;
            startMenuItem.OutlineColor = Color.Goldenrod;
            startMenuItem.ShadowColor  = Color.MidnightBlue;
            startMenuItem.ShadowVector = new Vector2(2, 2);

            // Exit menu item
            exitMenuItem              = new TextItemScreenComponent(core, menuFont2, exitMenuText, HorizontalAlignment.Right, VerticalAlignment.None);
            exitMenuItem.TextColor    = Color.White;
            exitMenuItem.OutlineColor = Color.Gold;
            exitMenuItem.ShadowColor  = Color.MidnightBlue;
            exitMenuItem.ShadowVector = new Vector2(2, 2);

            // Add items to stack panel
            stackPanel.Components.Add(title);
            stackPanel.Components.Add(version);
            stackPanel.Components.Add(new StackSpacerScreenComponent(core, 50));
            stackPanel.Components.Add(startMenuItem);
            stackPanel.Components.Add(new StackSpacerScreenComponent(core, 20));
            stackPanel.Components.Add(exitMenuItem);

            // Wire up menu events
            startMenuItem.OnMouseEnter += new EventHandler(StartMenuItem_OnMouseEnter);
            startMenuItem.OnMouseLeave += new EventHandler(StartMenuItem_OnMouseLeave);
            exitMenuItem.OnMouseEnter  += new EventHandler(ExitMenuItem_OnMouseEnter);
            exitMenuItem.OnMouseLeave  += new EventHandler(ExitMenuItem_OnMouseLeave);
            startMenuItem.OnMouseClick += new EventHandler(StartMenuItem_OnMouseClick);
            exitMenuItem.OnMouseClick  += new EventHandler(ExitMenuItem_OnMouseClick);
        }
        protected override void LoadContent()
        {
            // Load fonts
            consoleFont = Game.Content.Load <SpriteFont>("Fonts/MenuFont");

            core.Renderer.ShowDebugBuffers = true;

            // Load fonts
            SpriteFont menuFont2 = Game.Content.Load <SpriteFont>("Fonts/MenuFont2");

            // Create gui manager
            gui = new InterfaceManager(core);
            gui.SetMargins(Margins.All, 20);

            // Create status text
            physicsTextItem = new TextItemScreenComponent(core, menuFont2, string.Empty);
            physicsTextItem.EnableOutline       = true;
            physicsTextItem.OutlineColor        = Color.Gray;
            physicsTextItem.ShadowColor         = Color.Black;
            physicsTextItem.ShadowVector        = new Vector2(2, 2);
            physicsTextItem.HorizontalAlignment = HorizontalAlignment.Left;
            physicsTextItem.VerticalAlignment   = VerticalAlignment.Top;

            // Add to gui
            gui.Components.Add(physicsTextItem);

            // Create scene
            scene = new Scene(core);
            scene.Camera.Position = new Vector3(22, 27, -20);
            scene.Camera.Update();
            core.ActiveScene = scene;

            // Set day/night mode for window textures
            core.MaterialManager.Daytime = false;

            // Create level entity
            DynamicEntity level = new DynamicEntity(core.ActiveScene);

            // Create block component
            DaggerfallBlockComponent block = new DaggerfallBlockComponent(core);

            block.LoadBlock("S0000181.RDB", MapsFile.DefaultClimateSettings, core.ActiveScene, true);

            // Increase bounding sphere radius as block component does not current calculate properly
            block.BoundingSphere = new BoundingSphere(block.BoundingSphere.Center, block.BoundingSphere.Radius * 2);

            // Add block to level
            level.Components.Add(block);

            // Attach block flats
            AddBlockFlats(level, block);

            // Attach block lights
            AddBlockLights(level, block);

            // Add player point light
            playerLight = new LightComponent(core, Vector3.Zero, 7f, Color.White, 1f);
            level.Components.Add(playerLight);

            // Disable core input handling
            core.Input.ActiveDevices = Input.DeviceFlags.None;

            // Create player controller
            playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera);
            playerInput.UseCameraSmoothing            = true;
            playerInput.CharacterController.JumpSpeed = 9;
            playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8;
            playerInput.StandingCameraOffset = 1.4f;
            playerInput.Activate();

            // Initialise mouse state
            Game.IsMouseVisible = false;
            Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
            startMouseState = mouseState = Mouse.GetState();

            // Load songs
            MediaPlayer.Stop();
            song = Game.Content.Load <Song>("Songs/DanGoodale_DF-D2");
            MediaPlayer.Play(song);

            UpdatePhysicsObjectText();
        }