protected void draw_battle(SpriteBatch sprite_batch, GraphicsDevice device, RenderTarget2D mapRender, RenderTarget2D finalRender, RenderTarget2D tempRender, RenderTarget2D effectRender) { Effect battle_shader = Global.effect_shader(); // Map is on render target 0, so don't use it for anything // Render target 1 will act as the 'result' target // Draws to target 1 device.SetRenderTarget(finalRender); device.Clear(Color.Transparent); // If not doing level up foreground darken, draw the background now // Otherwise it happens at the end if (!level_up_layer_resort()) { draw_background_render(sprite_batch, device, tempRender, mapRender, effectRender); // Draw map and background to final render effectRender.raw_copy_render_target(sprite_batch, device, finalRender); } draw_battle(sprite_batch, device, finalRender, tempRender, effectRender, battle_shader); // If doing level up foreground darken, now it's time to draw the background if (level_up_layer_resort()) { draw_background_render(sprite_batch, device, finalRender, mapRender, tempRender); } // Draw map and background to final render device.SetRenderTarget(tempRender); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); sprite_batch.Draw(effectRender, Vector2.Zero, Color.White); sprite_batch.End(); // Draw render result device.SetRenderTarget(finalRender); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); sprite_batch.Draw(mapRender, Vector2.Zero, Color.White); sprite_batch.End(); //Rectangle scissor_rect = new Rectangle(16, 16, // Config.WINDOW_WIDTH - 16 * 2, // Config.WINDOW_HEIGHT - 16 * 2); Rectangle scissor_rect = new Rectangle(0, 0, Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT); sprite_batch.GraphicsDevice.ScissorRectangle = scissor_rect; sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, ScissorRasterState); sprite_batch.Draw(tempRender, Vector2.Zero, Color.White); sprite_batch.End(); }
public void draw(SpriteBatch sprite_batch, GraphicsDevice device, Tuple <Battler_Sprite, bool> active_battler_sprite, IEnumerable <Tuple <Battler_Sprite, bool> > inactive_battler_sprites, RenderTarget2D final_render, RenderTarget2D temp_render, RenderTarget2D effect_render) { Effect battle_shader = Global.effect_shader(); // Draw to a temporary target device.SetRenderTarget(temp_render); device.Clear(Color.Transparent); BattlerRenderCommands current_command = BattlerRenderCommands.NormalDraw; foreach (BattlerRenderCommands command in draw_battlers( sprite_batch, active_battler_sprite, inactive_battler_sprites)) { if (command != current_command) { // Apply distortion effect if (current_command == BattlerRenderCommands.DistortionDraw && command != current_command) { // Start drawing to effect_render device.SetRenderTarget(effect_render); device.Clear(Color.Transparent); // Draw final_render, using temp_render as a distortion map if (battle_shader != null) { battle_shader.CurrentTechnique = battle_shader.Techniques["Distortion"]; float larger_dimension = Math.Max(temp_render.Width, temp_render.Height); Vector2 mask_size_ratio = new Vector2(temp_render.Width / larger_dimension, temp_render.Height / larger_dimension); battle_shader.Parameters["mask_size_ratio"].SetValue(mask_size_ratio); #if __ANDROID__ // There has to be a way to do this for both battle_shader.Parameters["Map_Alpha"].SetValue(temp_render); #else sprite_batch.GraphicsDevice.Textures[1] = temp_render; #endif sprite_batch.GraphicsDevice.SamplerStates[1] = SamplerState.PointClamp; //Yeti //battle_shader.CurrentTechnique = battle_shader.Techniques["Tone"]; //battle_shader.Parameters["tone"].SetValue(Global.game_state.screen_tone.to_vector_4(Config.ACTION_BATTLER_TONE_WEIGHT / 255f)); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, battle_shader); sprite_batch.Draw(final_render, Vector2.Zero, Color.White); // on promotion (and level up?) darken this tint //Yeti sprite_batch.End(); // Copy effect_render to final_render effect_render.raw_copy_render_target(sprite_batch, device, final_render); // Start drawing to temp_render device.SetRenderTarget(temp_render); device.Clear(Color.Transparent); } if (command == BattlerRenderCommands.NormalDraw) { } else if (command == BattlerRenderCommands.DistortionDraw) { // Copy to final target with tone draw_battler_tone(sprite_batch, device, final_render, temp_render, battle_shader); // Start drawing to temp_render device.SetRenderTarget(temp_render); device.Clear(Color.Transparent); } else if (command == BattlerRenderCommands.Finish) { break; //draw_battler_tone(sprite_batch, device, final_render, temp_render, battle_shader); } current_command = command; } } // Copy to final target with tone draw_battler_tone(sprite_batch, device, final_render, temp_render, battle_shader); }