/// <summary> /// Draw the current state of the background screen. /// </summary> /// <param name="gameTime">Current time of the game.</param> public override void Draw(GameTime gameTime) { Viewport viewport = EngineManager.GameGraphicsDevice.Viewport; // Change the RenderTarget to the render capture to draw the model renderCapture.BeginRender(); GameGraphicsDevice.Clear(Color.Transparent); GameGraphicsDevice.DepthStencilState = DepthStencilState.Default; GameGraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; GameGraphicsDevice.BlendState = BlendState.AlphaBlend; GameGraphicsDevice.DepthStencilState = DepthStencilState.Default; _model.Draw(CameraManager.ActiveCamera.View, CameraManager.ActiveCamera.Projection, DrawingMethod.NoInstancing, _individualTransformations, null); postProcessor.Input = renderCapture.GetTexture(); // Aply the post processing effect renderCapture.InitEffect(); postProcessor.Draw(); renderCapture.EndEffect(); renderCapture.EndRender(); // Draw the background image ScreenManager.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, CanvasManager.ScaleMatrix); ScreenManager.SpriteBatch.Draw(TextureManager.GetTexture(backgroundTexture).BaseTexture as Texture2D, new Rectangle(0, 0, GameSettings.DefaultInstance.ResolutionWidth, GameSettings.DefaultInstance.ResolutionHeight), new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha)); // Draw the title ScreenManager.SpriteBatch.DrawString(ScreenManager.FontTitle, _menuTitle, _titlePosition, Color.White); ScreenManager.SpriteBatch.Draw(TextureManager.GetTexture("SeparationBar").BaseTexture, new Rectangle((int)_titlePosition.X, (int)(_titlePosition.Y + _titleSize.Y), (int)_titleSize.X, 5), Color.White); ScreenManager.SpriteBatch.End(); // Join the background and the model ScreenManager.SpriteBatch.Begin(); if (GameSettings.DefaultInstance.HighDetail) { ScreenManager.SpriteBatch.Draw(renderCapture._finalTarget, new Rectangle(0, 0, viewport.Width, viewport.Height), Color.White); } else { ScreenManager.SpriteBatch.Draw(renderCapture._renderTarget, new Rectangle(0, 0, viewport.Width, viewport.Height), Color.White); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0); GraphicsDevice.RenderState.CullMode = CullMode.None; GraphicsDevice.RenderState.DepthBufferEnable = true; GraphicsDevice.RenderState.AlphaBlendEnable = false; GraphicsDevice.RenderState.AlphaTestEnable = false; person1.Model.Bones[0].Transform = person1.OriginalTransforms[0] * Matrix.CreateRotationX(camera.UpDownRot) * Matrix.CreateRotationY(camera.LeftRightRot); person1.Draw(camera); for (int i = 0; i < models.Count; i++) { models[i].Draw(camera); } foreach (ModelMesh mesh in terrain.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = Matrix.Identity; effect.SpecularColor = new Vector3(1, 0, 0); effect.View = camera.ViewMatrix; effect.Projection = camera.ProjectionMatrix; } mesh.Draw(); } sky.Draw(camera.ViewMatrix, camera.ProjectionMatrix); //Demo Stuff if (input.KeyDown(Keys.I)) { postProc.PostProcess("Invert"); } if (input.KeyDown(Keys.T)) { postProc.PostProcess("TimeChange", (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f); } base.Draw(gameTime); }
/// <summary> /// Draw the current state of the <c>NewGameScreen</c> screen. /// </summary> /// <param name="gameTime">Current time of the game.</param> public override void Draw(GameTime gameTime) { if (!TextureManager.GetTexture("EasyDifficult").ReadyToRender || !TextureManager.GetTexture("NormalDifficult").ReadyToRender || !TextureManager.GetTexture("HardDifficult").ReadyToRender) { return; } ScreenManager.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, CanvasManager.ScaleMatrix); GameGraphicsDevice.DepthStencilState = DepthStencilState.Default; GameGraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; GameGraphicsDevice.BlendState = BlendState.AlphaBlend; GameGraphicsDevice.DepthStencilState = DepthStencilState.Default; // Draw the easy difficult float xPosition = _currentPosition.X; ScreenManager.SpriteBatch.Draw( TextureManager.GetTexture("DummyTexture15T").BaseTexture, new Rectangle((int)xPosition, (int)_currentPosition.Y, (int)_menuEntrySize.X, (int)_menuEntrySize.Y), !_selectedOption && _selectedDifficult == 0 ? Color.White : Color.SlateGray); ScreenManager.SpriteBatch.DrawString( ScreenManager.FontEntriesSelected, StringHelper.DefaultInstance.Get("difficult_easy"), new Vector2(xPosition, _currentPosition.Y), !_selectedOption && _selectedDifficult == 0 ? Color.White : Color.SlateGray); // Draw the normal difficult xPosition += (((GameSettings.DefaultInstance.ResolutionWidth / 2) - 30f) / 3); ScreenManager.SpriteBatch.Draw( TextureManager.GetTexture("DummyTexture15T").BaseTexture, new Rectangle((int)xPosition, (int)_currentPosition.Y, (int)_menuEntrySize.X, (int)_menuEntrySize.Y), !_selectedOption && _selectedDifficult == 1 ? Color.White : Color.SlateGray); ScreenManager.SpriteBatch.DrawString( ScreenManager.FontEntriesSelected, StringHelper.DefaultInstance.Get("difficult_normal"), new Vector2(xPosition, _currentPosition.Y), !_selectedOption && _selectedDifficult == 1 ? Color.White : Color.SlateGray); // Draw the hard difficult xPosition += (((GameSettings.DefaultInstance.ResolutionWidth / 2) - 30f) / 3); ScreenManager.SpriteBatch.Draw( TextureManager.GetTexture("DummyTexture15T").BaseTexture, new Rectangle((int)xPosition, (int)_currentPosition.Y, (int)_menuEntrySize.X, (int)_menuEntrySize.Y), !_selectedOption && _selectedDifficult == 2 ? Color.White : Color.SlateGray); ScreenManager.SpriteBatch.DrawString( ScreenManager.FontEntriesSelected, StringHelper.DefaultInstance.Get("difficult_hard"), new Vector2(xPosition, _currentPosition.Y), !_selectedOption && _selectedDifficult == 2 ? Color.White : Color.SlateGray); _currentPosition.Y += _menuEntrySize.Y + TextureManager.GetTexture("HardDifficult").BaseTexture.Height + _menuEntriesSeparation * 2; // Draw the accept and cancel buttons if (_selectedOption && !_selectedEnd) { ScreenManager.SpriteBatch.Draw(TextureManager.GetTexture("DummyTexture15T").BaseTexture, new Rectangle((int)_currentPosition.X, (int)_currentPosition.Y, (int)(GameSettings.DefaultInstance.ResolutionWidth / 4), (int)_menuEntrySize.Y), Color.White); } ScreenManager.SpriteBatch.DrawString( ScreenManager.FontEntriesSelected, StringHelper.DefaultInstance.Get("accept"), new Vector2(_currentPosition.X, _currentPosition.Y), _selectedOption && !_selectedEnd ? Color.White : Color.SlateGray); if (_selectedOption && _selectedEnd) { ScreenManager.SpriteBatch.Draw(TextureManager.GetTexture("DummyTexture15T").BaseTexture, new Rectangle((int)GameSettings.DefaultInstance.ResolutionWidth / 3, (int)_currentPosition.Y, (int)(GameSettings.DefaultInstance.ResolutionWidth / 4), (int)_menuEntrySize.Y), Color.White); } ScreenManager.SpriteBatch.DrawString( ScreenManager.FontEntriesSelected, StringHelper.DefaultInstance.Get("cancel"), new Vector2(GameSettings.DefaultInstance.ResolutionWidth / 3, (int)_currentPosition.Y), _selectedOption && _selectedEnd ? Color.White : Color.SlateGray); _model.Draw(CameraManager.ActiveCamera.View, CameraManager.ActiveCamera.Projection, DrawingMethod.NoInstancing, _individualTransformations, null); ScreenManager.SpriteBatch.End(); _currentPosition = _initialPosition; }