protected override void Draw(GameTime gameTime) { if (GameValues.Bloom) { bloom.Visible = true; } else { bloom.Visible = false; } bloom.BeginDraw(); GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); switch (GameValues.DrawMethod) { case 0: ParticleManager.DrawAsPoints(spriteBatch); break; case 1: ParticleManager.DrawAsArrows(spriteBatch); break; } spriteBatch.End(); base.Draw(gameTime); spriteBatch.Begin(); ParticleManager.DrawText(spriteBatch); FPSCounter.Draw(spriteBatch); spriteBatch.End(); }
protected override void Draw(GameTime gameTime) { _bloom.BeginDraw(); GraphicsDevice.Clear(Color.Black); _spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive); EntityManager.Draw(_spriteBatch); ParticleManager.Draw(_spriteBatch); _spriteBatch.End(); base.Draw(gameTime); _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive); _spriteBatch.DrawString(Art.Font, "Lives: " + PlayerStatus.Lives, new Vector2(5), Color.White); DrawRightAlignedString("Score: " + PlayerStatus.Score, 5); DrawRightAlignedString("Multiplier: " + PlayerStatus.Multiplier, 35); if (PlayerStatus.IsGameOver) { var text = string.Format("Game Over\nYour Score: {0}\nHigh Score: {1}", PlayerStatus.Score, PlayerStatus.HighScore); var textSize = Art.Font.MeasureString(text); _spriteBatch.DrawString(Art.Font, text, ScreenSize / 2 - textSize / 2, Color.White); } _spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White); _spriteBatch.End(); }
public void Draw(World world) { if ((CurrentRenderTarget == null || CurrentRenderTarget == DrawBuffer) && _NeoManager.ShowSoftwareCursor && EngineVariables.EnableGUI) { _NeoManager.BeginDraw(DefaultGameTime); GraphicsDevice.SetRenderTarget(CurrentRenderTarget); } if (world != null) { BloomEffect.Visible = (BloomEnabled && world.Get <RenderSettings>().BloomEnabled); if (BloomEffect.Visible) { BloomEffect.BeginDraw(); GraphicsDevice.Clear(Color.Black); Stage = RenderStage.Bloom; world.Draw(this); BloomEffect.Draw(world.Get <RenderSettings>().BloomSettings); } GraphicsDevice.SetRenderTarget(CurrentRenderTarget); Stage = RenderStage.PreBloom; world.Draw(this); if (!BloomEffect.Visible) { Stage = RenderStage.Bloom; world.Draw(this); } else { BloomEffect.Flush(); } Stage = RenderStage.PostBloom; world.Draw(this); } if ((CurrentRenderTarget == null || CurrentRenderTarget == DrawBuffer) && _NeoManager.ShowSoftwareCursor && EngineVariables.EnableGUI) { _NeoManager.EndDraw(); } GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.Black); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, null, null, null, DisplaySettings.ScaleMatrix); GraphicsDevice.Viewport = DisplaySettings.Viewport; SpriteBatch.Draw(DrawBuffer, Vector2.Zero, Color.White); SpriteBatch.End(); }
/// <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) { bloomShader.BeginDraw(); graphics.GraphicsDevice.Clear(Color.Black); m_gameStateManager.Draw(spriteBatch); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { bloom.BeginDraw(); Game1.graphics.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.get_transformation(game.GraphicsDevice)); background.Draw(spriteBatch); player.Draw(spriteBatch); enemyManager.Draw(spriteBatch); powerUpManager.Draw(spriteBatch); particleManager.Draw(cam.get_transformation(game.GraphicsDevice)); spriteBatch.End(); spriteBatch.Begin(); spriteBatch.Draw(crosshair, player.MousePosition - new Vector2(17 / 2, 9), Color.White); if (player.Score.ToString().Length > 5) { spriteBatch.DrawString(score, player.Score.ToString(), new Vector2(Game1.SCREEN_WIDTH - 185, -10), Color.White); } else { spriteBatch.DrawString(score, player.Score.ToString(), new Vector2(Game1.SCREEN_WIDTH - 160, -10), Color.White); } float xMargin = 15; for (int i = 0; i < player.Lives; i++) { spriteBatch.Draw(livesIcon, new Vector2(xMargin, 10), Color.White); xMargin += 50; } if (paused) { spriteBatch.Draw(PauseOverlay, new Vector2(0, 0), Color.White); spriteBatch.DrawString(score, "GAME PAUSED", new Vector2((game.GraphicsDevice.Viewport.Width / 2) - (score.MeasureString("GAME PAUSED").X / 2), (game.GraphicsDevice.Viewport.Height / 2) - (score.MeasureString("GAME PAUSED").Y / 2) - 100), Color.White); spriteBatch.DrawString(score, "Press ESC to resume", new Vector2((game.GraphicsDevice.Viewport.Width / 2) - (score.MeasureString("GAME PAUSED").X / 2) - 100, (game.GraphicsDevice.Viewport.Height / 2) - (score.MeasureString("GAME PAUSED").Y / 2)), Color.White); } if (gameOver) { spriteBatch.Draw(PauseOverlay, new Vector2(0, 0), Color.White); spriteBatch.DrawString(score, "GAME OVER", new Vector2((game.GraphicsDevice.Viewport.Width / 2) - (score.MeasureString("GAME OVER").X / 2), (game.GraphicsDevice.Viewport.Height / 2) - (score.MeasureString("GAME OVER").Y / 2) - 100), Color.DarkRed); spriteBatch.DrawString(score, "Score: " + player.Score, new Vector2( (game.GraphicsDevice.Viewport.Width / 2) - (score.MeasureString("Score: " + player.Score.ToString()).X / 2), (game.GraphicsDevice.Viewport.Height / 2) - (score.MeasureString("Score: " + player.Score.ToString()).Y / 2)), Color.GreenYellow); } 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) { if (enableBloom) { postProcessComponent.BeginDraw(); } SystemCore.Render(gameTime); 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) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here bloom.BeginDraw(); base.Draw(gameTime); gameScene.DrawUI(gameTime); textManager.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { bloom.BeginDraw(); if (!useBloom) { base.Draw(gameTime); } GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive); EntityManager.Draw(spriteBatch); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive); Grid.Draw(spriteBatch); ParticleManager.Draw(spriteBatch); spriteBatch.End(); if (useBloom) { base.Draw(gameTime); } // Draw the user interface without bloom spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive); spriteBatch.DrawString(Art.Font, "Lives: " + PlayerStatus.Lives, new Vector2(5), Color.White); DrawRightAlignedString("Score: " + PlayerStatus.Score, 5); DrawRightAlignedString("Multiplier: " + PlayerStatus.Multiplier, 35); // draw the custom mouse cursor spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White); if (PlayerStatus.IsGameOver) { string text = "Game Over\n" + "Your Score: " + PlayerStatus.Score + "\n" + "High Score: " + PlayerStatus.HighScore; Vector2 textSize = Art.Font.MeasureString(text); spriteBatch.DrawString(Art.Font, text, ScreenSize / 2 - textSize / 2, Color.White); } spriteBatch.End(); }
/// <summary> /// Draws the scene. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { this._timeRuler.BeginMark("Draw", Color.Yellow); #if XNA bloom.BeginDraw(); #endif this.GraphicsDevice.Clear(Color.Black); this.GraphicsDevice.RasterizerState = Rasterizer.Instance.State; base.Draw(gameTime); // Stop measuring time for "Draw". this._timeRuler.EndMark("Draw"); }
/// <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) { GraphicsDevice.Clear(Color.CornflowerBlue); bloom.BeginDraw(); spriteBatch.Begin(); //...draw all your stuff spriteBatch.Draw(background, new Rectangle(0, 0, graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, graphics.GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White); spriteBatch.End(); bloom.Draw(gameTime); base.Draw(gameTime); }
/// <summary> /// Renders the Game /// </summary> public void render() { //ActiveCamera.Position = Vector.Zero; Matrix transform = ActiveCamera != null ? ActiveCamera.TranformMatrix : Matrix.Identity; int bbWidth = GraphicsDevice.PresentationParameters.BackBufferWidth; int bbHeight = GraphicsDevice.PresentationParameters.BackBufferHeight; lightMapTarget = checkRenderTarget(lightMapTarget, bbWidth, bbHeight); layerScreenShader = checkRenderTarget(layerScreenShader, bbWidth, bbHeight); currentLayerTarget = checkRenderTarget(currentLayerTarget, bbWidth, bbHeight); bloomComponent.Settings = GameManager.Level.BloomSettings; bloomLightComponent.Settings = GameManager.Level.BloomLightSettings; //DRAW LIGHTMAP renderLightMap(GameManager.Objects.getAllObjects().Where(g => g.Active && !g.HudObject).ToList()); renderLayers(); bloomComponent.BeginDraw(); GraphicsDevice.Clear(Level.BackgroundColor); spriteBatch.Begin(); spriteBatch.Draw(layerScreenShader, Vector.Zero, XnaColor.White); spriteBatch.End(); bloomComponent.draw(); GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Textures[1] = bloomLightComponent.OutputTarget; Vector4 ambience = ((XnaColor)GameManager.Level.AmbientLight).ToVector4(); lightEffect.Parameters["ambience"].SetValue(ambience); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone, GameManager.Level.LightingEnabled ? lightEffect : null); spriteBatch.Draw(bloomComponent.OutputTarget, Vector.Zero, XnaColor.White); spriteBatch.End(); }
/// <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) { GraphicsDevice.Clear(Color.Black); bloom.BeginDraw(); spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive); EntityManager.Draw(spriteBatch); spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White); spriteBatch.End(); base.Draw(gameTime); spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive); EntityManager.Draw(spriteBatch); spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White); spriteBatch.DrawString(Art.Font, "Lives: " + PlayerStatus.Lives, new Vector2(5), Color.White); DrawRightAlignedString("Score: " + PlayerStatus.Score, 5); DrawRightAlignedString("Multiplier: " + PlayerStatus.Multiplier, 35); spriteBatch.End(); }
public void DrawBloom(GameTime gameTime, BloomComponent bloom, bool isBloom) { if (isBloom) { bloom.BeginDraw(_spriteBatch); } _spaceManager.DrawBackGround(cameraFollowing, Camera.Pos); _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Camera.get_transformation(_spriteBatch.GraphicsDevice)); _spaceManager.Draw(_spriteBatch, Camera.Pos, Zoom); _spriteBatch.End(); // Draw particles in different spritebatch. Otherwise they look absolutely awful. _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive, null, null, null, null, Camera.get_transformation(_spriteBatch.GraphicsDevice)); _spaceManager.DrawWarpZones(); _particleManager.Draw(_spriteBatch); _shipManager.ParticleDraw(_spriteBatch); _spriteBatch.End(); _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Camera.get_transformation(_spriteBatch.GraphicsDevice)); foreach (var s in _structures) { switch (s.buildingType) { case StructureTypes.LaserTurret: ((Turret)s).Draw(_spriteBatch); break; default: s.Update(); break; } } _projectileManager.Draw(Camera._pos); _shipManager.Draw(); //ParticleManager.DrawOnTop(spriteBatch); // Not needed atm. Needed when we use Charge effects, etc _spriteBatch.End(); //normal.Draw(spriteBatch, gameTime, ConvertUnits.ToDisplayUnits(shipPos), spaceCam); #if DEBUG //_spriteBatch.Begin(); //string the = ""+ShipManager.getPlayerShipDifference(); ////DebugTextManager.DrawTextToScreenLeft(_spriteBatch, 2, the); ////ProjectileManager.Debug(_spriteBatch); //_spriteBatch.End(); #endif if (isBloom) { bloom.Draw(_spriteBatch); } }
/// <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) { GraphicsDevice device = graphics.GraphicsDevice; Viewport viewport = device.Viewport; bloom.BeginDraw(); GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); // Everything in this sprite batch will have the bloom effect applied paddle.Draw(); wall.Draw(); gameBorder.Draw(); if (ball.Visible) { bool inPlay = ball.Move(wall, paddle); if (inPlay) { ball.Draw(); ParticleManager.Draw(spriteBatch); } else { ballsRemaining--; readyToServeBall = true; } } spriteBatch.End(); base.Draw(gameTime); // UI stuff spriteBatch.Begin(); // Everything in this sprite batch will NOT have the bloom effect applied staticBallIcon.Draw(); string scoreMsg = "Score: " + ball.Score.ToString("00000"); Vector2 space = gameContent.labelFont.MeasureString(scoreMsg); spriteBatch.DrawString(gameContent.labelFont, scoreMsg, new Vector2((screenWidth - space.X) / 2, screenHeight - 40), Color.White); if (ball.bricksCleared >= 70) { ball.Visible = false; ball.bricksCleared = 0; wall = new Wall(1, 50, spriteBatch, gameContent); readyToServeBall = true; } if (readyToServeBall) { if (ballsRemaining > 0) { string startMsg = "Press <Space> or Click Mouse to Start"; Vector2 startSpace = gameContent.labelFont.MeasureString(startMsg); spriteBatch.DrawString(gameContent.labelFont, startMsg, new Vector2((screenWidth - startSpace.X) / 2, screenHeight / 2), Color.White); } else { string endMsg = "Game Over"; Vector2 endSpace = gameContent.labelFont.MeasureString(endMsg); spriteBatch.DrawString(gameContent.labelFont, endMsg, new Vector2((screenWidth - endSpace.X) / 2, screenHeight / 2), Color.White); } } spriteBatch.DrawString(gameContent.labelFont, ballsRemaining.ToString(), new Vector2(40, 10), Color.White); spriteBatch.End(); }
/// <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) { GraphicsDevice device = graphics.GraphicsDevice; GraphicsDevice.Clear(new Color(50, 50, 50)); spriteBatch.Begin(0, BlendState.Opaque); bloom.Enabled = true; bloom.BeginDraw(); if (menu == 0) { spriteBatch.Draw(bgTexture, Vector2.Zero, Color.Red); } else if (menu == 1) { spriteBatch.Draw(bgTexture, Vector2.Zero, backgroundColor); } else if (menu == 2) { spriteBatch.Draw(bgTexture, Vector2.Zero, new Color(0, 1f, 0)); } spriteBatch.End(); spriteBatch.Begin(); bloom.BeginDraw(); if (menu == 0) { dummyPaddleLeft.Draw(gameTime, spriteBatch); dummyPaddleRight.Draw(gameTime, spriteBatch); dummyPong.Draw(gameTime, spriteBatch); spriteBatch.DrawString(system, "Neon Pong", new Vector2((windowSize.X) / 2, 25), Color.White, 0, new Vector2(250, 0), 1.0f, SpriteEffects.None, 0f); } else if (menu == 1) { paddleLeft.Draw(gameTime, spriteBatch); if (isPvp) { paddleRightPlayer.Draw(gameTime, spriteBatch); } else { paddleRight.Draw(gameTime, spriteBatch); } pong.Draw(gameTime, spriteBatch); } else if (menu == 2) { } spriteBatch.End(); device.DepthStencilState = DepthStencilState.Default; base.Draw(gameTime); spriteBatch.Begin(); /* * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[0].point1.X, MapSegments[0].point1.Y, MapSegments[0].point2.X, MapSegments[0].point2.Y), Color.White); * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[1].point1.X, MapSegments[1].point1.Y, MapSegments[1].point2.X, MapSegments[1].point2.Y), Color.White); * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[2].point1.X, MapSegments[2].point1.Y, MapSegments[2].point2.X, MapSegments[2].point2.Y), Color.White); * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[3].point1.X, MapSegments[3].point1.Y, MapSegments[3].point2.X, MapSegments[3].point2.Y), Color.White); * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[4].point1.X, MapSegments[4].point1.Y, MapSegments[4].point2.X, MapSegments[4].point2.Y), Color.White); * spriteBatch.Draw(textureBox, new Rectangle(MapSegments[5].point1.X, MapSegments[5].point1.Y, MapSegments[5].point2.X, MapSegments[5].point2.Y), Color.White); * for (int i = 0; i > 6; i++) * { * spriteBatch.Draw(textureBox, new Rectangle(PaddleSegments[i].point1.X, PaddleSegments[i].point1.Y, PaddleSegments[i].point2.X, PaddleSegments[i].point2.Y), Color.White); * } */ //debugLabel.Draw(gameTime, spriteBatch); if (menu == 0) { playButton.Draw(gameTime, spriteBatch); optionsButton.Draw(gameTime, spriteBatch); exitButton.Draw(gameTime, spriteBatch); pvpPlayButton.Draw(gameTime, spriteBatch); } else if (menu == 1) { score.Draw(gameTime, spriteBatch); if (gameOver && !paused) { endText.Draw(gameTime, spriteBatch); resetButton.Draw(gameTime, spriteBatch); mainMenuButton2.Draw(gameTime, spriteBatch); } if (paused) { pauseButton.Draw(gameTime, spriteBatch); paddleLeft.move = false; paddleRight.move = false; pong.move = false; paused = true; mainMenuButton.Draw(gameTime, spriteBatch); } if (!paused && isStarted && !gameOver) { paddleLeft.move = true; paddleRight.move = true; pong.move = true; paused = false; } if (ableStart && !gameOver && !isStarted) { startGameInst.Draw(gameTime, spriteBatch); } } else if (menu == 2) { bgColorRedUp.Draw(gameTime, spriteBatch); bgColorRedDown.Draw(gameTime, spriteBatch); bgColorGreenUp.Draw(gameTime, spriteBatch); spriteBatch.Draw(textureColor, new Rectangle(140, 128, 23, 23), new Color(bgColorR, bgColorG, bgColorB)); bgColorGreenDown.Draw(gameTime, spriteBatch); bgColorBlueUp.Draw(gameTime, spriteBatch); bgColorBlueDown.Draw(gameTime, spriteBatch); pLColorRedUp.Draw(gameTime, spriteBatch); pLColorRedDown.Draw(gameTime, spriteBatch); pLColorGreenUp.Draw(gameTime, spriteBatch); spriteBatch.Draw(textureColor, new Rectangle(368, 128, 23, 23), new Color(pLColorR, pLColorG, pLColorB)); pLColorGreenDown.Draw(gameTime, spriteBatch); pLColorBlueUp.Draw(gameTime, spriteBatch); pLColorBlueDown.Draw(gameTime, spriteBatch); pRColorRedUp.Draw(gameTime, spriteBatch); pRColorRedDown.Draw(gameTime, spriteBatch); pRColorGreenUp.Draw(gameTime, spriteBatch); spriteBatch.Draw(textureColor, new Rectangle(140, 292, 23, 23), new Color(pRColorR, pRColorG, pRColorB)); pRColorGreenDown.Draw(gameTime, spriteBatch); pRColorBlueUp.Draw(gameTime, spriteBatch); pRColorBlueDown.Draw(gameTime, spriteBatch); pColorRedUp.Draw(gameTime, spriteBatch); pColorRedDown.Draw(gameTime, spriteBatch); pColorGreenUp.Draw(gameTime, spriteBatch); spriteBatch.Draw(textureColor, new Rectangle(368, 292, 23, 23), new Color(pColorR, pColorG, pColorB)); pColorGreenDown.Draw(gameTime, spriteBatch); pColorBlueUp.Draw(gameTime, spriteBatch); pColorBlueDown.Draw(gameTime, spriteBatch); applyButton.Draw(gameTime, spriteBatch); cancelButton.Draw(gameTime, spriteBatch); backgoundLabel.Draw(gameTime, spriteBatch); paddleLeftLabel.Draw(gameTime, spriteBatch); paddleRightLabel.Draw(gameTime, spriteBatch); pongLabel.Draw(gameTime, spriteBatch); } spriteBatch.End(); // TODO: Add your drawing code here }
public override void Draw(GameTime gameTime) { _bloom.BeginDraw(); if (!_useBloom) { base.Draw(gameTime); } ControlManager.Draw(GameRef.SpriteBatch); var backgroundColor = new Color(50, 50, 50); GraphicsDevice.Clear(backgroundColor); // Draw game arena background GameRef.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, null, null, null, null, Players[0].Camera.GetTransformation()); GameRef.SpriteBatch.Draw(_backgroundImage, _backgroundMainRectangle, Color.White); GameRef.SpriteBatch.End(); GameRef.GraphicsDevice.DepthStencilState = DepthStencilState.Default; GameRef.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, Players[0].Camera.GetTransformation()); Players[0].Draw(gameTime); _boss.Draw(gameTime, Players[0].Camera.GetTransformation()); foreach (var bullet in Players[0].GetBullets()) { bullet.Draw(gameTime); } GameRef.ParticleManager.Draw(GameRef.SpriteBatch); GameRef.SpriteBatch.End(); if (_useBloom) { base.Draw(gameTime); } // Draw UI GameRef.SpriteBatch.Begin(); // Text /* * GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, * "Position: " + Players.First().GetPosition(), * new Vector2(0, 20), Color.White); */ GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Player's bullet: " + Players.First().GetBullets().Count, new Vector2(0, 20), Color.White); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Boss's bullet: " + _boss.MoverManager.movers.Count, new Vector2(0, 40), Color.White); var boundingBoxCount = 0; foreach (var part in _boss.Parts) { boundingBoxCount += part.CollisionBoxes.Count; } GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Bounding boxes: " + boundingBoxCount, new Vector2(0, 60), Color.White); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Boss core HP: " + _boss.BossCore.Hp, new Vector2(0, 80), Color.White); int startY = 120; int elementCount = 4; for (int i = 0; i < _boss.Parts.Count; i++) { GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Part #" + i + " position: " + _boss.Parts[i].Position, new Vector2(0, (startY + 20 * 1) + (elementCount * 20 * i) + (20 * i)), Color.White); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Part #" + i + " origin: " + _boss.Parts[i].Origin, new Vector2(0, (startY + 20 * 2) + (elementCount * 20 * i) + (20 * i)), Color.White); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Part #" + i + " rotation: " + Math.Round(_boss.Parts[i].Rotation, 2) + " (cos: " + Math.Round(Math.Cos(_boss.Parts[i].Rotation), 2) + ", sin: " + Math.Round(Math.Sin(_boss.Parts[i].Rotation), 2) + ")", new Vector2(0, (startY + 20 * 3) + (elementCount * 20 * i) + (20 * i)), Color.White); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Part #" + i + " area: " + Math.Round(_boss.Parts[i].GetArea(), 2), new Vector2(0, (startY + 20 * 4) + (elementCount * 20 * i) + (20 * i)), Color.White); } GameRef.SpriteBatch.End(); }
/// <summary> /// Called when a frame is to be drawn to the screen /// </summary> /// <param name="gameTime">The current time</param> public void Render(DwarfTime gameTime) { if (!ShowingWorld) { return; } var frustum = Camera.GetDrawFrustum(); var renderables = EnumerateIntersectingObjects(frustum) .Where(r => r.IsVisible && !ChunkManager.IsAboveCullPlane(r.GetBoundingBox())); // Controls the sky fog float x = (1.0f - Sky.TimeOfDay); x = x * x; DefaultShader.FogColor = new Color(0.32f * x, 0.58f * x, 0.9f * x); DefaultShader.LightPositions = LightPositions; CompositeLibrary.Render(GraphicsDevice); CompositeLibrary.Update(); GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; // Computes the water height. float wHeight = WaterRenderer.GetVisibleWaterHeight(ChunkManager, Camera, GraphicsDevice.Viewport, lastWaterHeight); lastWaterHeight = wHeight; // Draw reflection/refraction images WaterRenderer.DrawReflectionMap(renderables, gameTime, this, wHeight - 0.1f, GetReflectedCameraMatrix(wHeight), DefaultShader, GraphicsDevice); #region Draw Selection Buffer. if (SelectionBuffer == null) { SelectionBuffer = new SelectionBuffer(8, GraphicsDevice); } GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; Plane slicePlane = WaterRenderer.CreatePlane(SlicePlane, new Vector3(0, -1, 0), Camera.ViewMatrix, false); if (SelectionBuffer.Begin(GraphicsDevice)) { // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.World = Matrix.Identity; //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Chunks"); ChunkRenderer.RenderSelectionBuffer(DefaultShader, GraphicsDevice, Camera.ViewMatrix); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Chunks"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Components"); ComponentRenderer.RenderSelectionBuffer(renderables, gameTime, ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Components"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Instances"); InstanceRenderer.Flush(GraphicsDevice, DefaultShader, Camera, InstanceRenderMode.SelectionBuffer); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Instances"); SelectionBuffer.End(GraphicsDevice); } #endregion // Start drawing the bloom effect if (GameSettings.Default.EnableGlow) { bloom.BeginDraw(); } // Draw the sky GraphicsDevice.Clear(DefaultShader.FogColor); DrawSky(gameTime, Camera.ViewMatrix, 1.0f, DefaultShader.FogColor); // Defines the current slice for the GPU float level = ChunkManager.World.Master.MaxViewingLevel + 0.25f; if (level > VoxelConstants.ChunkSizeY) { level = 1000; } SlicePlane = level; DefaultShader.WindDirection = Weather.CurrentWind; DefaultShader.WindForce = 0.0005f * (1.0f + (float)Math.Sin(Time.GetTotalSeconds() * 0.001f)); // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; //Blue ghost effect above the current slice. DefaultShader.GhostClippingEnabled = true; Draw3DThings(gameTime, DefaultShader, Camera.ViewMatrix); // Now we want to draw the water on top of everything else DefaultShader.ClippingEnabled = true; DefaultShader.GhostClippingEnabled = false; //ComponentManager.CollisionManager.DebugDraw(); DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.GhostClippingEnabled = true; // Now draw all of the entities in the game DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; if (Debugger.Switches.DrawOcttree) { foreach (var box in OctTree.EnumerateBounds(frustum)) { Drawer3D.DrawBox(box.Item2, Color.Yellow, 1.0f / (float)(box.Item1 + 1), false); } } // Render simple geometry (boxes, etc.) Drawer3D.Render(GraphicsDevice, DefaultShader, Camera, DesignationDrawer, PlayerFaction.Designations, this); DefaultShader.EnableShadows = false; DefaultShader.View = Camera.ViewMatrix; ComponentRenderer.Render(renderables, gameTime, ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader, ComponentRenderer.WaterRenderType.None, lastWaterHeight); InstanceRenderer.Flush(GraphicsDevice, DefaultShader, Camera, InstanceRenderMode.Normal); if (Master.CurrentToolMode == GameMaster.ToolMode.BuildZone || Master.CurrentToolMode == GameMaster.ToolMode.BuildWall || Master.CurrentToolMode == GameMaster.ToolMode.BuildObject) { DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.SetTexturedTechnique(); GraphicsDevice.BlendState = BlendState.NonPremultiplied; } WaterRenderer.DrawWater( GraphicsDevice, (float)gameTime.TotalGameTime.TotalSeconds, DefaultShader, Camera.ViewMatrix, GetReflectedCameraMatrix(wHeight), Camera.ProjectionMatrix, new Vector3(0.1f, 0.0f, 0.1f), Camera, ChunkManager); ParticleManager.Render(this, GraphicsDevice); DefaultShader.ClippingEnabled = false; if (GameSettings.Default.EnableGlow) { bloom.DrawTarget = UseFXAA ? fxaa.RenderTarget : null; if (UseFXAA) { fxaa.Begin(DwarfTime.LastTime); } bloom.Draw(gameTime.ToRealTime()); if (UseFXAA) { fxaa.End(DwarfTime.LastTime); } } else if (UseFXAA) { fxaa.End(DwarfTime.LastTime); } RasterizerState rasterizerState = new RasterizerState() { ScissorTestEnable = true }; if (Debugger.Switches.DrawSelectionBuffer) { SelectionBuffer.DebugDraw(GraphicsDevice.Viewport.Bounds); } try { DwarfGame.SafeSpriteBatchBegin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, Drawer2D.PointMagLinearMin, null, rasterizerState, null, Matrix.Identity); //DwarfGame.SpriteBatch.Draw(Shadows.ShadowTexture, Vector2.Zero, Color.White); if (IsCameraUnderwater()) { Drawer2D.FillRect(DwarfGame.SpriteBatch, GraphicsDevice.Viewport.Bounds, new Color(10, 40, 60, 200)); } Drawer2D.Render(DwarfGame.SpriteBatch, Camera, GraphicsDevice.Viewport); IndicatorManager.Render(gameTime); } finally { DwarfGame.SpriteBatch.End(); } if (Debugger.Switches.DrawComposites) { Vector2 offset = Vector2.Zero; foreach (var composite in CompositeLibrary.Composites) { offset = composite.Value.DebugDraw(DwarfGame.SpriteBatch, (int)offset.X, (int)offset.Y); } } Master.Render(Game, gameTime, GraphicsDevice); DwarfGame.SpriteBatch.GraphicsDevice.ScissorRectangle = DwarfGame.SpriteBatch.GraphicsDevice.Viewport.Bounds; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; lock (ScreenshotLock) { foreach (Screenshot shot in Screenshots) { TakeScreenshot(shot.FileName, shot.Resolution); } Screenshots.Clear(); } }
public void renderLightMap(List <GameObject> gobs, List <InstanceDescriptor> insts) { ConvexHull.InitializeStaticMembers(GraphicsDevice); EffectParameter widthParameter = lightEffect.Parameters["screenWidth"]; EffectParameter heightParameter = lightEffect.Parameters["screenHeight"]; setShaderValue(widthParameter, lightMapTarget.Width); setShaderValue(heightParameter, lightMapTarget.Height); GraphicsDevice.SetRenderTarget(lightMapTarget); GraphicsDevice.Clear(XnaColor.Transparent); insts.ForEach(i => { if (i.Light.Visible) { ClearAlphaToOne(); GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.BlendState = CustomBlendStates.MultiplyShadows; //shadowing algorithm taken from http://www.catalinzima.com/xna/samples/dynamic-2d-shadows/ if (Level.PreviewShadowing) { insts.ForEach(hull => { if (hull.Shadows.CastsShadows) { Boolean pass = hull != i; if (i.Shadows.SelfShadows) { pass = true; } if (pass) { Convex convex = hull.Bounds.Convex; convex.Origin = hull.Position; convex.Rotation = hull.Sprite.Rotation; ConvexHull convexHull = new ConvexHull(convex, WhiskeyColor.White); convexHull.DrawShadows(i.Light, CameraTransform, hull.Shadows.IncludeLight, hull.Shadows.Solidness, hull.Shadows.Height); } } }); } spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.MultiplyWithAlpha, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, CameraTransform); i.renderLight(RenderInfo); spriteBatch.End(); } }); ClearAlphaToOne(); lightBloomComponent.BeginDraw(); GraphicsDevice.Clear(XnaColor.Transparent); spriteBatch.Begin(); spriteBatch.Draw(lightMapTarget, Vector.Zero, null, XnaColor.White); spriteBatch.End(); lightBloomComponent.draw(); lightMapTarget = lightBloomComponent.OutputTarget; }
public void renderAll(List <GameObject> gobs, List <InstanceDescriptor> insts) { //get width and height of window int bbWidth = GraphicsDevice.PresentationParameters.BackBufferWidth; int bbHeight = GraphicsDevice.PresentationParameters.BackBufferHeight; //initialize bloom component if (bloomComponent == null) { bloomComponent = new BloomComponent(GraphicsDevice, WhiskeyControl.Content); bloomComponent.loadContent(); bloomComponent.Settings = BloomSettings.PresetSettings[0]; } if (lightBloomComponent == null) { lightBloomComponent = new BloomComponent(GraphicsDevice, WhiskeyControl.Content); lightBloomComponent.loadContent(); lightBloomComponent.Settings = BloomSettings.PresetSettings[5]; } //load bloom settings if (Level.BloomSettings != null) { bloomComponent.Settings = Level.BloomSettings; } if (Level.LightBloomSettings != null) { lightBloomComponent.Settings = Level.LightBloomSettings; } //ensure render targets are correctly sized hudTarget = checkRenderTarget(hudTarget, bbWidth, bbHeight); lightMapTarget = checkRenderTarget(lightMapTarget, bbWidth, bbHeight); sceneTarget = checkRenderTarget(sceneTarget, bbWidth, bbHeight); hudObjectsTarget = checkRenderTarget(hudObjectsTarget, 1280, 720); layerScreenShader = checkRenderTarget(layerScreenShader, bbWidth, bbHeight); currentLayerTarget = checkRenderTarget(currentLayerTarget, bbWidth, bbHeight); //get game objects, and ui gameobjects List <GameObject> uiGameObjects = new List <GameObject>(); List <GameObject> gobsToRender = new List <GameObject>(); gobs.ForEach(g => uiGameObjects.Add(g)); insts.Where(g => !g.HudObject).ToList().ForEach(g => gobsToRender.Add(g)); //DRAW HUD renderHud(); //draw light radius gobsToRender.ForEach(g => { if (g.Light.Visible) { Convex convex = new Convex(g.Position, 0, VectorSet.Dodecahedren * (g.Light.Radius / 2)); convex.render(GraphicsDevice, CameraTransform, new RenderHints().setColor(Level.BackgroundColor.Inverted)); } }); //DRAW GAME OBJECTS // bloomComponent.BeginDraw(); render(gobsToRender); bloomComponent.BeginDraw(); GraphicsDevice.Clear(Level.BackgroundColor); spriteBatch.Begin(); spriteBatch.Draw(layerScreenShader, Vector.Zero, XnaColor.White); spriteBatch.End(); bloomComponent.draw(); //DRAW LIGHTMAP renderLightMap(gobs, insts.Where(g => !g.HudObject).ToList()); //DRAW SCENE WITH LIGHTMAP GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Textures[1] = lightMapTarget; Vector4 ambience = ((XnaColor)Level.AmbientLight).ToVector4(); lightEffect.Parameters["ambience"].SetValue(ambience); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone, Level.PreviewLighting ? lightEffect : null); spriteBatch.Draw(bloomComponent.OutputTarget, Vector.Zero, XnaColor.White); spriteBatch.End(); //DRAW HUD spriteBatch.Begin(); spriteBatch.Draw(hudTarget, Vector.Zero, XnaColor.White); spriteBatch.End(); }
protected override void Draw(GameTime gameTime) { bloom.BeginDraw(); GraphicsDevice.Clear(Color.Black); spriteBatch.Begin();//SpriteSortMode.Texture, BlendState.Additive spriteBatch.Draw(whiteBoxTexture, new Rectangle((int)(0), (int)0, screenWidth, screenHeight), null, Color.White * .1f); if (state == 0) { //spriteBatch.Draw(introTexture, new Rectangle(0, 0, (int)screenWidth, (int)screenHeight), Color.White); spriteBatch.DrawString(font1, "New Game", new Vector2((int)(screenWidth / 2) - 90, (int)(screenHeight * 4 / 7)), new Color(0, 215, 255, 150)); spriteBatch.DrawString(font1, "Leaderboards", new Vector2((int)(screenWidth / 2) - 90, (int)(screenHeight * 5 / 7)), new Color(0, 215, 255, 150)); spriteBatch.DrawString(font1, "Exit", new Vector2((int)(screenWidth / 2) - 90, (int)(screenHeight * 6 / 7)), new Color(0, 215, 255, 150)); spriteBatch.Draw(whiteBorderTexture, new Rectangle((int)((screenWidth * 1 / 2) - (300 / 2)), (int)((screenHeight * ((selectorLocation + 4)) / 7) - (75 / 2)), 300, 75), null, Color.LimeGreen); } if (state == 1 || state == 3) { //Draw Grid grid.Draw(spriteBatch, leftSideLoc); foreach (Enemy enemy in enemyList) { spriteBatch.Draw(enemy.enemyTexture, new Rectangle((int)enemy.location.X, (int)enemy.location.Y, 50, 50), null, Color.White, enemy.getRotation, new Vector2(50, 50), SpriteEffects.None, 1); } foreach (Bullet b in bulletList) { spriteBatch.Draw(bulletTexture, new Rectangle((int)b.location.X, (int)b.location.Y, 8, 8), null, Color.White, (float)b.angle, new Vector2(0, 0), SpriteEffects.None, 1); grid.ApplyExplosiveForce(5, b.location, 10); } foreach (ParticleObject p in particleList) { spriteBatch.Draw(whiteBoxTexture, new Rectangle((int)p.getLocation().X, (int)p.getLocation().Y, 4, 12), null, (new Color(p.rColor, p.gColor, p.bColor) * (p.transparency)), p.rotation, new Vector2(5, 5), SpriteEffects.None, 1); spriteBatch.Draw(whiteBoxTexture, new Rectangle((int)p.getLocation().X, (int)p.getLocation().Y, 2, 8), null, (Color.White) * (p.transparency) * .8f, p.rotation, new Vector2(5, 5), SpriteEffects.None, 1); } foreach (Multiplier m in multiplierList) { spriteBatch.Draw(blueBoxTexture, new Rectangle((int)m.getLocation().X, (int)m.getLocation().Y, 12, 12), Color.White); } spriteBatch.Draw(shipTexture, new Rectangle((int)ship.location.X, (int)ship.location.Y, 55, 55), null, Color.White, leftStickAngle, new Vector2(50, 50), SpriteEffects.None, 1); //Score and Lives string scoreStr = score.ToString(); spriteBatch.DrawString(font1, scoreStr, scorePos, new Color(0, 215, 255, 150)); spriteBatch.DrawString(font1, "Score", new Vector2(scorePos.X, scorePos.Y - 25), new Color(0, 215, 255, 150)); spriteBatch.DrawString(font1, multiplierTotal.ToString(), new Vector2(scorePos.X, scorePos.Y + 25), Color.White); string livesStr = lives.ToString(); spriteBatch.DrawString(font1, livesStr, new Vector2(25, 50), new Color(0, 215, 255, 150)); spriteBatch.DrawString(font1, "Lives", new Vector2(25, 25), new Color(0, 215, 255, 150)); //Draw Border spriteBatch.Draw(blueBoxTexture, leftSide, Color.White); spriteBatch.Draw(blueBoxTexture, rightSide, Color.White); spriteBatch.Draw(blueBoxTexture, topSide, Color.White); spriteBatch.Draw(blueBoxTexture, bottomSide, Color.White); int outerEdge = 7; spriteBatch.Draw(blueBoxTexture, new Rectangle((int)leftSideLoc.X - outerEdge, (int)leftSideLoc.Y - outerEdge, 3, screenHeight + 150 + 2 * outerEdge), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)rightSideLoc.X + outerEdge, (int)rightSideLoc.Y - outerEdge, 3, screenHeight + 150 + 2 * outerEdge), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)topSideLoc.X - outerEdge, (int)topSideLoc.Y - outerEdge, screenWidth + 20 + 2 * outerEdge, 3), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)bottomSideLoc.X - outerEdge, (int)bottomSideLoc.Y + outerEdge, screenWidth + 20 + 2 * outerEdge, 3), Color.White); //High Score Border if (state == 3) { spriteBatch.Draw(blueBoxTexture, new Rectangle((int)((screenWidth * 1 / 2) - (300 / 2)), (int)((screenHeight * 7 / 10) - (75 / 2)), 300, 75), null, Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)((screenWidth * 1 / 2) - (300 / 2)), (int)((screenHeight * 8 / 10) - (75 / 2)), 300, 75), null, Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)((screenWidth * 1 / 2) - (300 / 2)), (int)((screenHeight * 9 / 10) - (75 / 2)), 300, 75), null, Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)((screenWidth * 1 / 2) - 200), (int)((screenHeight * ((selectorLocation + 7)) / 10) - (20 / 2)), 15, 15), null, Color.White); } } if (state == 2) { foreach (ParticleObject p in particleList) { spriteBatch.Draw(p.texture, new Rectangle((int)p.getLocation().X, (int)p.getLocation().Y, 5, 10), null, new Color(255, 255, 255, (byte)p.transparency), p.rotation, new Vector2(5, 5), SpriteEffects.None, 1); } //Score and Lives string scoreStr = score.ToString(); spriteBatch.DrawString(font1, scoreStr, scorePos, Color.White); spriteBatch.DrawString(font1, "Score", new Vector2(scorePos.X, scorePos.Y - 25), Color.White); spriteBatch.DrawString(font1, multiplierTotal.ToString(), new Vector2(scorePos.X, scorePos.Y + 25), Color.White); string livesStr = lives.ToString(); spriteBatch.DrawString(font1, livesStr, new Vector2(100, 50), Color.White); int y = 75; foreach (int i in highScores) { y += 100; string hscoreString = i.ToString(); spriteBatch.DrawString(font1, hscoreString, new Vector2(screenWidth / 2 - 170, y), Color.White); } //High Score spriteBatch.DrawString(font1, "High Scores", new Vector2(screenWidth / 2 - 80, 100), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle(screenWidth / 2 - 250, 50, 5, screenHeight - 100), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle(screenWidth / 2 - 250, 50, 505, 5), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle(screenWidth / 2 - 250, screenHeight - 50, 505, 5), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle(screenWidth / 2 + 250, 50, 5, screenHeight - 100), Color.White); //Draw Border spriteBatch.Draw(blueBoxTexture, leftSide, Color.White); spriteBatch.Draw(blueBoxTexture, rightSide, Color.White); spriteBatch.Draw(blueBoxTexture, topSide, Color.White); spriteBatch.Draw(blueBoxTexture, bottomSide, Color.White); int outerEdge = 7; spriteBatch.Draw(blueBoxTexture, new Rectangle((int)leftSideLoc.X - outerEdge, (int)leftSideLoc.Y - outerEdge, 3, screenHeight + 150 + 2 * outerEdge), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)rightSideLoc.X + outerEdge, (int)rightSideLoc.Y - outerEdge, 3, screenHeight + 150 + 2 * outerEdge), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)topSideLoc.X - outerEdge, (int)topSideLoc.Y - outerEdge, screenWidth + 20 + 2 * outerEdge, 3), Color.White); spriteBatch.Draw(blueBoxTexture, new Rectangle((int)bottomSideLoc.X - outerEdge, (int)bottomSideLoc.Y + outerEdge, screenWidth + 20 + 2 * outerEdge, 3), Color.White); } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Called when a frame is to be drawn to the screen /// </summary> /// <param name="gameTime">The current time</param> public void Render(DwarfTime gameTime) { if (!World.ShowingWorld) { return; } ValidateShader(); var frustum = Camera.GetDrawFrustum(); var renderables = World.EnumerateIntersectingObjects(frustum, r => r.IsVisible && !World.ChunkManager.IsAboveCullPlane(r.GetBoundingBox())); // Controls the sky fog float x = (1.0f - Sky.TimeOfDay); x = x * x; DefaultShader.FogColor = new Color(0.32f * x, 0.58f * x, 0.9f * x); DefaultShader.LightPositions = LightPositions; CompositeLibrary.Render(GraphicsDevice); CompositeLibrary.Update(); GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; if (lastWaterHeight < 0) // Todo: Seriously, every single frame?? { lastWaterHeight = 0; foreach (var chunk in World.ChunkManager.ChunkMap) { for (int y = 0; y < VoxelConstants.ChunkSizeY; y++) { if (chunk.Data.LiquidPresent[y] > 0) { lastWaterHeight = Math.Max(y + chunk.Origin.Y, lastWaterHeight); } } } } // Computes the water height. float wHeight = WaterRenderer.GetVisibleWaterHeight(World.ChunkManager, Camera, GraphicsDevice.Viewport, lastWaterHeight); lastWaterHeight = wHeight; // Draw reflection/refraction images WaterRenderer.DrawReflectionMap(renderables, gameTime, World, wHeight - 0.1f, GetReflectedCameraMatrix(wHeight), DefaultShader, GraphicsDevice); #region Draw Selection Buffer. if (SelectionBuffer == null) { SelectionBuffer = new SelectionBuffer(8, GraphicsDevice); } GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; // Defines the current slice for the GPU var level = PersistentSettings.MaxViewingLevel >= World.WorldSizeInVoxels.Y ? 1000.0f : PersistentSettings.MaxViewingLevel + 0.25f; Plane slicePlane = WaterRenderer.CreatePlane(level, new Vector3(0, -1, 0), Camera.ViewMatrix, false); if (SelectionBuffer.Begin(GraphicsDevice)) { // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.World = Matrix.Identity; //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Chunks"); ChunkRenderer.RenderSelectionBuffer(DefaultShader, GraphicsDevice, Camera.ViewMatrix); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Chunks"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Components"); ComponentRenderer.RenderSelectionBuffer(renderables, gameTime, World.ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Components"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Instances"); InstanceRenderer.Flush(GraphicsDevice, DefaultShader, Camera, InstanceRenderMode.SelectionBuffer); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Instances"); SelectionBuffer.End(GraphicsDevice); } #endregion // Start drawing the bloom effect if (GameSettings.Default.EnableGlow) { bloom.BeginDraw(); } // Draw the sky GraphicsDevice.Clear(DefaultShader.FogColor); DrawSky(gameTime, Camera.ViewMatrix, 1.0f, DefaultShader.FogColor); DefaultShader.FogEnd = GameSettings.Default.ChunkDrawDistance; DefaultShader.FogStart = GameSettings.Default.ChunkDrawDistance * 0.8f; CaveView = CaveView * 0.9f + TargetCaveView * 0.1f; DefaultShader.WindDirection = World.Weather.CurrentWind; DefaultShader.WindForce = 0.0005f * (1.0f + (float)Math.Sin(World.Time.GetTotalSeconds() * 0.001f)); // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; //Blue ghost effect above the current slice. DefaultShader.GhostClippingEnabled = true; Draw3DThings(gameTime, DefaultShader, Camera.ViewMatrix); // Now we want to draw the water on top of everything else DefaultShader.ClippingEnabled = true; DefaultShader.GhostClippingEnabled = false; //ComponentManager.CollisionManager.DebugDraw(); DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.GhostClippingEnabled = true; // Now draw all of the entities in the game DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; // Render simple geometry (boxes, etc.) Drawer3D.Render(GraphicsDevice, DefaultShader, Camera, World.PersistentData.Designations, World); DefaultShader.EnableShadows = false; DefaultShader.View = Camera.ViewMatrix; ComponentRenderer.Render(renderables, gameTime, World.ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader, ComponentRenderer.WaterRenderType.None, lastWaterHeight); InstanceRenderer.Flush(GraphicsDevice, DefaultShader, Camera, InstanceRenderMode.Normal); if (World.UserInterface.CurrentToolMode == "BuildZone" || // Todo: ?? World.UserInterface.CurrentToolMode == "BuildWall" || World.UserInterface.CurrentToolMode == "BuildObject") { DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.SetTexturedTechnique(); GraphicsDevice.BlendState = BlendState.NonPremultiplied; } WaterRenderer.DrawWater( GraphicsDevice, (float)gameTime.TotalGameTime.TotalSeconds, DefaultShader, Camera.ViewMatrix, GetReflectedCameraMatrix(wHeight), Camera.ProjectionMatrix, new Vector3(0.1f, 0.0f, 0.1f), Camera, World.ChunkManager); World.ParticleManager.Render(World, GraphicsDevice); DefaultShader.ClippingEnabled = false; if (UseFXAA && fxaa == null) { fxaa = new FXAA(); fxaa.Initialize(); } if (GameSettings.Default.EnableGlow) { if (UseFXAA) { fxaa.Begin(DwarfTime.LastTime); } bloom.DrawTarget = UseFXAA ? fxaa.RenderTarget : null; bloom.Draw(gameTime.ToRealTime()); if (UseFXAA) { fxaa.End(DwarfTime.LastTime); } } else if (UseFXAA) { fxaa.End(DwarfTime.LastTime); } RasterizerState rasterizerState = new RasterizerState() { ScissorTestEnable = true }; if (Debugger.Switches.DrawSelectionBuffer) { SelectionBuffer.DebugDraw(GraphicsDevice.Viewport.Bounds); } try { DwarfGame.SafeSpriteBatchBegin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, Drawer2D.PointMagLinearMin, null, rasterizerState, null, Matrix.Identity); //DwarfGame.SpriteBatch.Draw(Shadows.ShadowTexture, Vector2.Zero, Color.White); if (IsCameraUnderwater()) { Drawer2D.FillRect(DwarfGame.SpriteBatch, GraphicsDevice.Viewport.Bounds, new Color(10, 40, 60, 200)); } Drawer2D.Render(DwarfGame.SpriteBatch, Camera, GraphicsDevice.Viewport); IndicatorManager.Render(gameTime); } finally { try { DwarfGame.SpriteBatch.End(); } catch (Exception exception) { DwarfGame.SpriteBatch = new SpriteBatch(GraphicsDevice); } } if (Debugger.Switches.DrawComposites) { Vector2 offset = Vector2.Zero; foreach (var composite in CompositeLibrary.Composites) { offset = composite.Value.DebugDraw(DwarfGame.SpriteBatch, (int)offset.X, (int)offset.Y); } } DwarfGame.SpriteBatch.GraphicsDevice.ScissorRectangle = DwarfGame.SpriteBatch.GraphicsDevice.Viewport.Bounds; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; foreach (var module in World.UpdateSystems) { module.Render(gameTime, World.ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader); } lock (ScreenshotLock) { foreach (Screenshot shot in Screenshots) { TakeScreenshot(shot.FileName, shot.Resolution); } Screenshots.Clear(); } }
protected override void Draw(GameTime gameTime) { //FIX POSTPROCESSING spriteBatch.Begin(); spriteBatch.End(); BloomComponent.BeginDraw(); GraphicsDevice.Clear(Color.Black); for (int i = 0; i < CelestialBodies.Count; i++) { if (CelestialBodies[i].RenderWithBloom) { CelestialBodies[i].Render(); } } base.Draw(gameTime); Grid.Render(Observer.Camera.ViewMatrix, Observer.Camera.ProjectionsMatrix, Matrix.CreateTranslation(new Vector3(CelestialBody.GLOBALX - 3500000, CelestialBody.GLOBALY, CelestialBody.GLOBALZ - 3500000))); GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; for (int i = 0; i < CelestialBodies.Count; i++) { CelestialBodies[i].DrawEllipsoid(); if (!CelestialBodies[i].RenderWithBloom) { spriteBatch.Begin(); spriteBatch.End(); var v1 = Vector3.Zero; var v2 = new Vector3((float)CelestialBodies[i].XCoord + CelestialBody.GLOBALX, (float)CelestialBodies[i].ZCoord + CelestialBody.GLOBALY, (float)CelestialBodies[i].YCoord + CelestialBody.GLOBALZ); var direction = v2 - v1; direction.Normalize(); Ray Ray = new Ray(Vector3.Zero, direction); CelestialBodies[i].IsAllowedToRender = !(Ray.Intersects(CelestialBodies.Find(p => p.Name == "Sun").BoundingBox) > 1) || (v2 - v1).Length() < (new Vector3(CelestialBody.GLOBALX, CelestialBody.GLOBALY, CelestialBody.GLOBALZ) - v1).Length(); CelestialBodies[i].Render(); } spriteBatch.Begin(); CelestialBodies[i].DrawInformation(spriteBatch); spriteBatch.End(); if (ShowDebug) { BoundingBoxRenderer.Render(CelestialBodies[i].BoundingBox, GraphicsDevice, Observer.Camera.ViewMatrix, Observer.Camera.ProjectionsMatrix, Color.Red); } } _total_frames++; if (ShowDebug) { spriteBatch.Begin(); Observer.Camera.RenderDebug(spriteBatch, DebugFont); CelestialBody.DrawDebug(spriteBatch, DebugFont); spriteBatch.DrawString(DebugFont, fps + " frames per second", new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth - UI.Width - 150, 15), Color.White); spriteBatch.End(); } }
/// <summary> /// /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { bloom.BeginDraw(); GraphicsDevice.Clear(Color.Black); if (kinectbool && kinect != null) { camera1.Position = kinect.Headposition; } else { } camera1.LookAt = camera1.Position + new Vector3(0, 0, -3f); camera1.UpdateView(); rotation = MathHelper.WrapAngle(rotation); //float angle; //angle = MathHelper.Clamp((float)Math.Atan(ScreenWidth / (2 * camera1.Position.Z)) * 2, 0.0001f, MathHelper.Pi - 0.0001f);//获得头部角度 //angle = 0.35877067f; #region 通过投影方式计算投影矩阵 switch (pMethod) { case ProjectMethod.XNAProjection: graphDealer.Projection = MatrixHelper.CreateXNAProjection(Vector3.Normalize(Vector3.Zero - camera1.Position) , camera1.Position.Z , ScreenWidth , AspectRatio , 0.01f , 7000f); break; case ProjectMethod.IlluProjection: #region 得到偏斜矩阵,详情请访问我们的参赛博客。 illuMatrix = MatrixHelper.CreateIlluMatrix(Vector3.Normalize(Vector3.Zero - camera1.Position)); #endregion //graphDealer.Projection = // illuMatrix * // Matrix.CreatePerspectiveFieldOfView(angle, //待编辑 // AspectRatio, // 0.01f, // 7000.0f); float a = 0.01f / camera1.Position.Z; graphDealer.Projection = illuMatrix * Matrix.CreatePerspective(ScreenWidth * a, ScreenWidth / AspectRatio * a, 0.01f, 7000f); break; default: break; } #endregion graphDealer.Update(gameTime); #region 画天空包 Matrix[] skytransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(skytransforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.TextureEnabled = true; if (skyTexture != null) { effect.Texture = skyTexture; } effect.AmbientLightColor = new Vector3(1, 1, 1); effect.World = skytransforms[mesh.ParentBone.Index] * Matrix.CreateScale(100.0f) * Matrix.CreateRotationY(MathHelper.ToRadians(-60)) * Matrix.CreateRotationY(rotation) * Matrix.CreateTranslation(camera1.Position); effect.View = camera1.View; effect.Projection = graphDealer.Projection; } mesh.Draw(); } #endregion models[currentIndex].YawPitchRaw = new Vector3(rotation, 0, 0); models[currentIndex].Draw(gameTime, graphDealer.Camera.View, graphDealer.Projection); base.Draw(gameTime); SpriteBatch.Begin(); string s = "Head Position: " + camera1.Position.ToString() + "\nRotation: " + rotation + "\nKinect Position: " + KinectComponent.KinectOffset.ToString() //+ "FieldofView: " //+ MathHelper.ToDegrees(angle).ToString() + "\nScreen Width: " + ScreenWidth + "\nAspectRatio: " + AspectRatio + "\nPress Space to switch to the next scene."; if (!kinectbool) { s += "\nPress W, S, A, D, Q, E to change view."; } SpriteBatch.DrawString(Content.Load <SpriteFont>("defaultFont"), s, new Vector2(20, 20), Color.White); SpriteBatch.End(); }
public override void Draw(GameTime gameTime) { _bloom.BeginDraw(); ControlManager.Draw(GameRef.SpriteBatch); GameRef.SpriteBatch.Begin(0, BlendState.Opaque); /* * GameRef.SpriteBatch.Draw(_background, new Rectangle( * (int)(Config.Resolution.X / 2f), (int)(Config.Resolution.Y / 2f), * Config.Resolution.X * 2, Config.Resolution.Y * 2), * null, Color.White, _counter, new Vector2(_background.Width / 2f, _background.Height / 2f), SpriteEffects.None, 0f); */ GameRef.SpriteBatch.End(); GameRef.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Color backgroundColor = new Color(5, 5, 5); GraphicsDevice.Clear(backgroundColor); if (_singlePlayer) { GameRef.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Players[0].Camera.GetTransformation()); Color randomColor = Color.White;//new Color(Rand.Next(255), Rand.Next(255), Rand.Next(255)); GameRef.SpriteBatch.Draw(_backgroundImage, _backgroundMainRectangle, randomColor); foreach (var bullet in Players[0].GetBullets()) { bullet.Draw(gameTime); } Players[0].Draw(gameTime); /* * if (_enemy.IsAlive) * { * _enemy.Draw(gameTime); * } */ GameRef.SpriteBatch.End(); } else { if (Players[1].IsInvincible) { // Player 2 GraphicsDevice.Viewport = rightView; DrawPlayerCamera(gameTime, Players[1]); // Player 1 GraphicsDevice.Viewport = leftView; DrawPlayerCamera(gameTime, Players[0]); } else { // Player 1 GraphicsDevice.Viewport = leftView; DrawPlayerCamera(gameTime, Players[0]); // Player 2 GraphicsDevice.Viewport = rightView; DrawPlayerCamera(gameTime, Players[1]); } GraphicsDevice.Viewport = defaultView; } base.Draw(gameTime); GameRef.SpriteBatch.Begin(); _timer.Draw(gameTime); if (!_singlePlayer) { GameRef.SpriteBatch.Draw(_pixel, new Rectangle((int)(Config.Resolution.X / 2 - 2), 0, 2, Config.Resolution.Y), Color.Black); } foreach (Player p in Players) { if (p.IsAlive) { p.DrawString(gameTime); } } // Text if (Config.Debug) { GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Boss bullets: " + _enemy.MoverManager.movers.Count.ToString(CultureInfo.InvariantCulture), new Vector2(1, 21), Color.Black); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, "Boss bullets: " + _enemy.MoverManager.movers.Count.ToString(CultureInfo.InvariantCulture), new Vector2(0, 20), Color.White); } // Wave number string waveNumber = "Wave #" + _waveNumber.ToString(CultureInfo.InvariantCulture); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, waveNumber, new Vector2(Config.Resolution.X / 2f - ControlManager.SpriteFont.MeasureString(waveNumber).X / 2f + 1, Config.Resolution.Y - 49), Color.Black); GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, waveNumber, new Vector2(Config.Resolution.X / 2f - ControlManager.SpriteFont.MeasureString(waveNumber).X / 2f, Config.Resolution.Y - 50), Color.White); // Boss current pattern /* * if (Config.Debug) * { * GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, _enemy.GetCurrentPatternName(), * new Vector2( * Config.Resolution.X / 2f - * ControlManager.SpriteFont.MeasureString( * _enemy.GetCurrentPatternName()).X / 2, * Config.Resolution.Y - 25), * Color.Black); * GameRef.SpriteBatch.DrawString(ControlManager.SpriteFont, _enemy.GetCurrentPatternName(), * new Vector2( * Config.Resolution.X / 2f - * ControlManager.SpriteFont.MeasureString( * _enemy.GetCurrentPatternName()).X / 2 + 1, * Config.Resolution.Y - 26), * Color.White); * } */ GameRef.SpriteBatch.End(); }
/// <summary> /// Called when a frame is to be drawn to the screen /// </summary> /// <param name="gameTime">The current time</param> public void Render(DwarfTime gameTime) { if (!ShowingWorld) { return; } #if RENDER_VOXEL_ICONS var voxels = VoxelLibrary.RenderIcons(GraphicsDevice, DefaultShader, ChunkManager, -1, -1, 32); using (var stream = new FileStream("voxels.png", FileMode.OpenOrCreate)) { GraphicsDevice.SetRenderTarget(null); voxels.SaveAsPng(stream, voxels.Width, voxels.Height); } #endif GamePerformance.Instance.StartTrackPerformance("Render - RENDER"); GamePerformance.Instance.StartTrackPerformance("Render - Prep"); var renderables = ComponentRenderer.EnumerateVisibleRenderables(ComponentManager.GetRenderables(), ChunkManager, Camera); // Controls the sky fog float x = (1.0f - Sky.TimeOfDay); x = x * x; DefaultShader.FogColor = new Color(0.32f * x, 0.58f * x, 0.9f * x); DefaultShader.LightPositions = LightPositions; CompositeLibrary.Render(GraphicsDevice); CompositeLibrary.Update(); GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; if (GameSettings.Default.UseDynamicShadows) { ChunkRenderer.RenderShadowmap(DefaultShader, GraphicsDevice, Shadows, Matrix.Identity, Tilesheet); } if (GameSettings.Default.UseLightmaps) { ChunkRenderer.RenderLightmaps(Camera, gameTime, GraphicsDevice, DefaultShader, Matrix.Identity); } // Computes the water height. float wHeight = WaterRenderer.GetVisibleWaterHeight(ChunkManager, Camera, GraphicsDevice.Viewport, lastWaterHeight); lastWaterHeight = wHeight; // Draw reflection/refraction images WaterRenderer.DrawReflectionMap(renderables, gameTime, this, wHeight - 0.1f, GetReflectedCameraMatrix(wHeight), DefaultShader, GraphicsDevice); GamePerformance.Instance.StopTrackPerformance("Render - Prep"); GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer"); #region Draw Selection Buffer. if (SelectionBuffer == null) { SelectionBuffer = new SelectionBuffer(8, GraphicsDevice); } GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; Plane slicePlane = WaterRenderer.CreatePlane(SlicePlane, new Vector3(0, -1, 0), Camera.ViewMatrix, false); if (SelectionBuffer.Begin(GraphicsDevice)) { // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.World = Matrix.Identity; //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Chunks"); ChunkRenderer.RenderSelectionBuffer(DefaultShader, GraphicsDevice, Camera.ViewMatrix); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Chunks"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Components"); ComponentRenderer.RenderSelectionBuffer(renderables, gameTime, ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Components"); //GamePerformance.Instance.StartTrackPerformance("Render - Selection Buffer - Instances"); NewInstanceManager.RenderInstances(GraphicsDevice, DefaultShader, Camera, InstanceRenderer.RenderMode.SelectionBuffer); //GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer - Instances"); SelectionBuffer.End(GraphicsDevice); GamePerformance.Instance.TrackValueType("SBUFFER RENDERED", true); } else { GamePerformance.Instance.TrackValueType("SBUFFER RENDERED", false); } #endregion GamePerformance.Instance.StopTrackPerformance("Render - Selection Buffer"); GamePerformance.Instance.StartTrackPerformance("Render - BG Stuff"); // Start drawing the bloom effect if (GameSettings.Default.EnableGlow) { bloom.BeginDraw(); } // Draw the sky GraphicsDevice.Clear(DefaultShader.FogColor); DrawSky(gameTime, Camera.ViewMatrix, 1.0f, DefaultShader.FogColor); // Defines the current slice for the GPU float level = ChunkManager.ChunkData.MaxViewingLevel + 0.25f; if (level > VoxelConstants.ChunkSizeY) { level = 1000; } GamePerformance.Instance.StopTrackPerformance("Render - BG Stuff"); GamePerformance.Instance.StartTrackPerformance("Render - Chunks"); SlicePlane = level; DefaultShader.WindDirection = Weather.CurrentWind; DefaultShader.WindForce = 0.0005f * (1.0f + (float)Math.Sin(Time.GetTotalSeconds() * 0.001f)); // Draw the whole world, and make sure to handle slicing DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; //Blue ghost effect above the current slice. DefaultShader.GhostClippingEnabled = true; Draw3DThings(gameTime, DefaultShader, Camera.ViewMatrix); GamePerformance.Instance.StopTrackPerformance("Render - Chunks"); // Now we want to draw the water on top of everything else DefaultShader.ClippingEnabled = true; DefaultShader.GhostClippingEnabled = false; //ComponentManager.CollisionManager.DebugDraw(); DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.GhostClippingEnabled = true; // Now draw all of the entities in the game DefaultShader.ClipPlane = new Vector4(slicePlane.Normal, slicePlane.D); DefaultShader.ClippingEnabled = true; GamePerformance.Instance.StartTrackPerformance("Render - Drawer3D"); // Render simple geometry (boxes, etc.) Drawer3D.Render(GraphicsDevice, DefaultShader, Camera, DesignationDrawer, PlayerFaction.Designations, this); GamePerformance.Instance.StopTrackPerformance("Render - Drawer3D"); GamePerformance.Instance.StartTrackPerformance("Render - Instances"); DefaultShader.EnableShadows = GameSettings.Default.UseDynamicShadows; if (GameSettings.Default.UseDynamicShadows) { Shadows.BindShadowmapEffect(DefaultShader); } DefaultShader.View = Camera.ViewMatrix; NewInstanceManager.RenderInstances(GraphicsDevice, DefaultShader, Camera, InstanceRenderer.RenderMode.Normal); GamePerformance.Instance.StopTrackPerformance("Render - Instances"); GamePerformance.Instance.StartTrackPerformance("Render - Components"); ComponentRenderer.Render(renderables, gameTime, ChunkManager, Camera, DwarfGame.SpriteBatch, GraphicsDevice, DefaultShader, ComponentRenderer.WaterRenderType.None, lastWaterHeight); GamePerformance.Instance.StopTrackPerformance("Render - Components"); GamePerformance.Instance.StartTrackPerformance("Render - Tools"); if (Master.CurrentToolMode == GameMaster.ToolMode.BuildZone || Master.CurrentToolMode == GameMaster.ToolMode.BuildWall || Master.CurrentToolMode == GameMaster.ToolMode.BuildObject) { DefaultShader.View = Camera.ViewMatrix; DefaultShader.Projection = Camera.ProjectionMatrix; DefaultShader.SetTexturedTechnique(); GraphicsDevice.BlendState = BlendState.NonPremultiplied; Master.Faction.CraftBuilder.Render(gameTime, GraphicsDevice, DefaultShader); } GamePerformance.Instance.StopTrackPerformance("Render - Tools"); GamePerformance.Instance.StartTrackPerformance("Render - Water"); WaterRenderer.DrawWater( GraphicsDevice, (float)gameTime.TotalGameTime.TotalSeconds, DefaultShader, Camera.ViewMatrix, GetReflectedCameraMatrix(wHeight), Camera.ProjectionMatrix, new Vector3(0.1f, 0.0f, 0.1f), Camera, ChunkManager); GamePerformance.Instance.StopTrackPerformance("Render - Water"); GamePerformance.Instance.StartTrackPerformance("Render - Misc"); DefaultShader.ClippingEnabled = false; if (GameSettings.Default.EnableGlow) { bloom.DrawTarget = UseFXAA ? fxaa.RenderTarget : null; if (UseFXAA) { fxaa.Begin(DwarfTime.LastTime, fxaa.RenderTarget); } bloom.Draw(gameTime.ToGameTime()); if (UseFXAA) { fxaa.End(DwarfTime.LastTime, fxaa.RenderTarget); } } else if (UseFXAA) { fxaa.End(DwarfTime.LastTime, fxaa.RenderTarget); } RasterizerState rasterizerState = new RasterizerState() { ScissorTestEnable = true }; //if (CompositeLibrary.Composites.ContainsKey("resources")) // CompositeLibrary.Composites["resources"].DebugDraw(DwarfGame.SpriteBatch, 0, 0); //SelectionBuffer.DebugDraw(GraphicsDevice.Viewport.Bounds); try { DwarfGame.SafeSpriteBatchBegin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, Drawer2D.PointMagLinearMin, null, rasterizerState, null, Matrix.Identity); //DwarfGame.SpriteBatch.Draw(Shadows.ShadowTexture, Vector2.Zero, Color.White); if (IsCameraUnderwater()) { Drawer2D.FillRect(DwarfGame.SpriteBatch, GraphicsDevice.Viewport.Bounds, new Color(10, 40, 60, 200)); } Drawer2D.Render(DwarfGame.SpriteBatch, Camera, GraphicsDevice.Viewport); IndicatorManager.Render(gameTime); } finally { DwarfGame.SpriteBatch.End(); } Master.Render(Game, gameTime, GraphicsDevice); DwarfGame.SpriteBatch.GraphicsDevice.ScissorRectangle = DwarfGame.SpriteBatch.GraphicsDevice.Viewport.Bounds; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GamePerformance.Instance.StopTrackPerformance("Render - Misc"); GamePerformance.Instance.StopTrackPerformance("Render - RENDER"); lock (ScreenshotLock) { foreach (Screenshot shot in Screenshots) { TakeScreenshot(shot.FileName, shot.Resolution); } Screenshots.Clear(); } }