Beispiel #1
0
        /// <summary>
        /// Draws the entire scene in the given render target.
        /// </summary>
        /// <returns>A texture2D with the scene drawn in it.</returns>
        protected static void UpdateRegimentalTexture(Regiment r, RenderTarget2D renderTarget, GraphicsDevice GraphicsDevice, SpriteBatch spriteBatch, SpriteFont CounterFont)
        {
            // Set the render target
            GraphicsDevice.SetRenderTarget(renderTarget);

            GraphicsDevice.DepthStencilState = new DepthStencilState()
            {
                DepthBufferEnable = true
            };

            // Draw the scene
            GraphicsDevice.Clear(Color.CornflowerBlue);
            //DrawModel(model, world, view, projection);


            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
                              SamplerState.LinearClamp, DepthStencilState.Default,
                              RasterizerState.CullNone);

            GameRenderer.DrawRegimentToTexture(r, spriteBatch, CounterFont);
            spriteBatch.End();

            // Drop the render target
            GraphicsDevice.SetRenderTarget(null);
        }
Beispiel #2
0
 internal static void DrawAllRegiments(SinglePlayerAleaBelliGame abgame, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
 {
     foreach (Regiment r in abgame.AllRegiments)
     {
         RenderTarget2D renderTarget;
         // does the texture exists or is the regiment 'dirty'
         if (regimentTextures.TryGetValue(r.RegimentId, out renderTarget))
         {
             GameRenderer.DrawRegimentFromTexture(r, spriteBatch, renderTarget);
         }
     }
 }
Beispiel #3
0
        internal static void DrawRegimentFromTexture(Regiment r, SpriteBatch spriteBatch, RenderTarget2D renderTarget)
        {
            int width  = r.CurrentWidth;
            int height = r.CurrentHeight + 20;

            spriteBatch.Draw(renderTarget, new Rectangle(r.MapX, r.MapY, width, height), new Rectangle(0, 0, width, height),
                             Color.White,
                             GameRenderer.ConvertDegreesToRadians(r.FacingInDegrees),
                             Vector2.Zero,
                             SpriteEffects.None,
                             0
                             );
        }