protected void draw_events(SpriteBatch sprite_batch, Vector2 offset) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); Zoomed_Out_Map.draw(sprite_batch); if (Beacon != null) { Beacon.draw(sprite_batch, offset); } foreach (Flashing_Worldmap_Object sprite in Worldmap_Objects) { sprite.draw(sprite_batch, offset); } foreach (Worldmap_Unit unit in Units.OrderBy(x => x.loc.Y)) { unit.draw(sprite_batch, offset); } sprite_batch.End(); Effect effect = Global.effect_shader(); if (effect != null) { effect.CurrentTechnique = effect.Techniques["Technique1"]; } foreach (Worldmap_Unit unit in Clearing_Units) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, effect); if (effect != null) { unit.set_sprite_batch_effects(effect); } unit.draw(sprite_batch, offset); sprite_batch.End(); } }
private void draw_background_render(SpriteBatch sprite_batch, GraphicsDevice device, RenderTarget2D tempRender, RenderTarget2D mapRender, RenderTarget2D backgroundRender) { Effect battle_shader = Global.effect_shader(); // Draw background to temporary target device.SetRenderTarget(tempRender); device.Clear(Color.Transparent); draw_background(sprite_batch); // Draw map to temp render device.SetRenderTarget(backgroundRender); device.Clear(Color.Transparent); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); sprite_batch.Draw(mapRender, Vector2.Zero, Color.White); sprite_batch.End(); // Draw background to map with tone if (battle_shader != null) { battle_shader.CurrentTechnique = battle_shader.Techniques["Tone"]; battle_shader.Parameters["tone"].SetValue( Global.game_state.screen_tone.to_vector_4( Global.BattleSceneConfig.ActionBackgroundToneWeight / 255f)); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, battle_shader); sprite_batch.Draw(tempRender, Vector2.Zero, Color.White); sprite_batch.End(); }
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(); }
protected void draw_hud(SpriteBatch sprite_batch) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); if (Hit_Spark != null) { Hit_Spark.draw(sprite_batch); } Vector2 number_vector = (Layer_3_Shake + Platform_1_Shake + Platform_2_Shake) * 0.5f + Pan_Vector; foreach (var number in HitNumbers) { number.draw(sprite_batch, new Vector2((int)number_vector.X, (int)number_vector.Y)); } sprite_batch.End(); if (HUD != null) { HUD.draw(sprite_batch, Layer_5_Shake); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); if (Miss_Spark != null) { Miss_Spark.draw(sprite_batch, Pan_Vector); } if (NoDamage_Spark != null) { NoDamage_Spark.draw(sprite_batch, Pan_Vector); } sprite_batch.End(); if (Exp_Gauge != null) { sprite_batch.GraphicsDevice.ScissorRectangle = fix_rect_to_screen(Exp_Gauge.scissor_rect()); if (sprite_batch.GraphicsDevice.ScissorRectangle.Width > 0 && sprite_batch.GraphicsDevice.ScissorRectangle.Width > 0) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, Exp_Gauge.raster_state); Exp_Gauge.draw(sprite_batch); sprite_batch.End(); } } Effect battle_shader = Global.effect_shader(); if (Battler_1_Sprite != null) { Battler_1_Sprite.draw_fg_effects(sprite_batch, battle_shader, Pan_Vector); } if (Battler_2_Sprite != null) { Battler_2_Sprite.draw_fg_effects(sprite_batch, battle_shader, Pan_Vector); } draw_skill_gain_popup(sprite_batch); draw_wlvl_popup(sprite_batch); draw_wbreak_popup(sprite_batch); }
protected override void draw_background(SpriteBatch sprite_batch) { Effect background_shader = Global.effect_shader(); if (background_shader != null) { background_shader.CurrentTechnique = background_shader.Techniques["Tone"]; background_shader.Parameters["tone"].SetValue(Global.game_state.screen_tone.to_vector_4(1.0f)); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, background_shader); Background.draw(sprite_batch); sprite_batch.End(); }
protected void draw_battler_upper_effects(SpriteBatch sprite_batch) { Effect battle_shader = Global.effect_shader(); if (Battler_1_Sprite != null) { Battler_1_Sprite.draw_upper_effects(sprite_batch, battle_shader, Pan_Vector, Effects_Pan_Vector); } if (Battler_2_Sprite != null) { Battler_2_Sprite.draw_upper_effects(sprite_batch, battle_shader, Pan_Vector, Effects_Pan_Vector); } }
protected override void draw_background(SpriteBatch sprite_batch) { if (Background != null) { Effect effect = Global.effect_shader(); if (effect != null) { effect.CurrentTechnique = effect.Techniques["Tone"]; effect.Parameters["tone"].SetValue(Global.game_state.screen_tone.to_vector_4(1.0f)); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, effect); Background.draw(sprite_batch); sprite_batch.End(); } }
protected void draw_banner_scene(SpriteBatch sprite_batch) { // Title Screen Background Title_Back.draw(sprite_batch); // Title Background Darken sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); Title_Black.draw(sprite_batch); sprite_batch.End(); // Class Banner Effect banner_shader = Global.effect_shader(); if (banner_shader != null) { banner_shader.CurrentTechnique = banner_shader.Techniques["Technique2"]; banner_shader.Parameters["color_shift"].SetValue(Class_Banner_Color.ToVector4()); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, banner_shader); Class_Banner.draw(sprite_batch); sprite_batch.End(); // Letters if (Letters.Count > 0) { if (banner_shader != null) { banner_shader.CurrentTechnique = banner_shader.Techniques["Technique2"]; banner_shader.Parameters["color_shift"].SetValue(Letters[0].flash.ToVector4()); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, banner_shader); foreach (Spiral_Letter letter in Letters) { letter.draw(sprite_batch); } sprite_batch.End(); } if (Burst != null) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null); Burst.draw(sprite_batch); sprite_batch.End(); } }
public void draw_sprites(SpriteBatch sprite_batch) { if (Data != null) { // Units Effect unit_shader = Global.effect_shader(); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, unit_shader); if (unit_shader != null) { unit_shader.CurrentTechnique = unit_shader.Techniques["Technique2"]; unit_shader.Parameters["color_shift"].SetValue(new Color(255, 255, 255, Unit_Alpha).ToVector4()); } foreach (Minimap_Unit unit in Units) { int tint = unit.Ready ? 255 : 128; sprite_batch.Draw(Sprite_Texture, unit.Loc + Map_Offset, new Rectangle((unit.Team - 1) * MINIMAP_TILE_SIZE, 0, MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE), new Color(tint, tint, tint, 255)); } sprite_batch.End(); } }
public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2)) { Effect icon_shader = Global.effect_shader(); if (icon_shader != null) { icon_shader.CurrentTechnique = icon_shader.Techniques["Technique1"]; icon_shader.Parameters["color_shift"].SetValue(new Color(Flash_Color.R, Flash_Color.G, Flash_Color.B, Flash ? (Flash_Timer <= (Flash_Time_Max / 2) ? Flash_Timer : Flash_Time_Max - Flash_Timer) * 255 / (Flash_Time_Max / 2) : 0).ToVector4()); icon_shader.Parameters["opacity"].SetValue(1f); } if (Scissor) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, Scissor_State, icon_shader); } else { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, icon_shader); } base.draw(sprite_batch, draw_offset); sprite_batch.End(); }
public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2)) { if (textures.Count > 0) { if (visible) { // Background sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); Rectangle src_rect = this.src_rect; Vector2 offset = this.offset; if (mirrored) { offset.X = src_rect.Width - offset.X; } sprite_batch.Draw(textures[0], this.loc + draw_vector(), src_rect, tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); sprite_batch.End(); // Columns Effect column_shader = Global.effect_shader(); if (column_shader != null) { column_shader.CurrentTechnique = column_shader.Techniques["Technique2"]; } for (int i = Columns.Count - 1; i >= 0; i--) { Title_Column column = Columns[i]; if (column_shader != null) { column_shader.Parameters["color_shift"].SetValue(column.color.ToVector4()); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, column_shader); column.draw(sprite_batch); sprite_batch.End(); } } } }
public void draw_view(SpriteBatch sprite_batch) { if (Active && Data != null) { // View Area Effect unit_shader = Global.effect_shader(); if (unit_shader != null) { unit_shader.CurrentTechnique = unit_shader.Techniques["Technique2"]; unit_shader.Parameters["color_shift"].SetValue(new Color(0, 0, 0, View_Alpha).ToVector4()); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, unit_shader); sprite_batch.Draw(Sprite_Texture, View_Offset + Map_Offset, new Rectangle(0, 4, 8, 8), Color.White); sprite_batch.Draw(Sprite_Texture, View_Offset + Map_Offset + new Vector2(View_Area.X, 0), new Rectangle(8, 4, 8, 8), Color.White); sprite_batch.Draw(Sprite_Texture, View_Offset + Map_Offset + new Vector2(0, View_Area.Y), new Rectangle(0, 12, 8, 8), Color.White); sprite_batch.Draw(Sprite_Texture, View_Offset + Map_Offset + View_Area, new Rectangle(8, 12, 8, 8), Color.White); sprite_batch.End(); } }
protected void draw_animation_scene(SpriteBatch sprite_batch, GraphicsDevice device, RenderTarget2D final_render, RenderTarget2D temp_render, RenderTarget2D effect_render) { Effect reel_shader = Global.effect_shader(); // Background sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); Background.draw(sprite_batch); sprite_batch.End(); // Spell Bg if (Battler != null) { Battler.draw_bg_effects(sprite_batch, reel_shader); } // Platform Platform.draw(sprite_batch); // Battler if (Battler != null) { BattleSpriteRenderer battler_renderer = new BattleSpriteRenderer( false, Vector2.Zero, Vector2.Zero, Vector2.Zero); battler_renderer.draw(sprite_batch, device, new Tuple <Battler_Sprite, bool>(Battler, false), null, final_render, temp_render, effect_render); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); /*if (Battler != null) //Debug * { * sprite_batch.End(); * Battler.draw_lower_effects(sprite_batch, reel_shader); * Battler.draw_lower(sprite_batch, Vector2.Zero, reel_shader); * Battler.draw(sprite_batch, Vector2.Zero, reel_shader); * Battler.draw_upper(sprite_batch, Vector2.Zero, reel_shader); * sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); * }*/ // Stats if (Message != null) { foreach (Class_Reel_Stat_Bars bar in Stat_Bars) { bar.draw(sprite_batch); } foreach (TextSprite label in Stat_Labels) { label.draw(sprite_batch); } foreach (TextSprite value in Stat_Values) { value.draw(sprite_batch); } foreach (Icon_Sprite icon in Weapon_Icons) { icon.draw(sprite_batch); } Name_Bg.draw(sprite_batch); } // Battler if (Battler != null) { sprite_batch.End(); Battler.draw_upper_effects(sprite_batch, reel_shader); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); } // Name/Message if (Message != null) { Text_Bg.draw(sprite_batch); Name.draw(sprite_batch); sprite_batch.End(); // Message Message.draw_background(sprite_batch); Message.draw_faces(sprite_batch); Message.draw_foreground(sprite_batch); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); } // Spell Fg if (Battler != null) { sprite_batch.End(); Battler.draw_fg_effects(sprite_batch, reel_shader); sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); White_Flash.draw(sprite_batch); } // Black Screen Black_Screen.draw(sprite_batch); Black_Bar1.draw(sprite_batch); Black_Bar2.draw(sprite_batch); sprite_batch.End(); }
public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2)) { if (texture != null) { if (visible) { if (palette_exists) { Effect effect = Global.effect_shader(); if (effect != null) { Texture2D palette_texture = Global.palette_pool.get_palette(); palette_texture.SetData <Color>(Palette); #if __ANDROID__ // There has to be a way to do this for both effect.Parameters["Palette"].SetValue(palette_texture); #else sprite_batch.GraphicsDevice.Textures[2] = palette_texture; #endif sprite_batch.GraphicsDevice.SamplerStates[2] = SamplerState.PointClamp; effect.CurrentTechnique = effect.Techniques["Palette1"]; effect.Parameters["color_shift"].SetValue(new Vector4(0, 0, 0, 0)); effect.Parameters["opacity"].SetValue(1f); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, effect); } else { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); } Rectangle src_rect = this.src_rect; Vector2 offset = this.offset; if (mirrored) { offset.X = src_rect.Width - offset.X; } // Body if (Dest_Rect != null) { sprite_batch.Draw(texture, (Rectangle)Dest_Rect, src_rect, tint, angle, offset, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); } else { sprite_batch.Draw(texture, this.loc + draw_vector() - draw_offset, src_rect, tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); } sprite_batch.End(); #if __ANDROID__ // There has to be a way to do this for both if (Global.effect_shader() != null) { Global.effect_shader().Parameters["Palette"].SetValue((Texture2D)null); } #else sprite_batch.GraphicsDevice.Textures[2] = null; #endif } } }
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); }
public void draw_map(SpriteBatch sprite_batch) { if (Data != null) { // Map int width = Minimap_Texture.Width / MINIMAP_TILE_SIZE; // Fow tiles Color fog_color = Color.White; Effect unit_shader = Global.effect_shader(); if (unit_shader != null) { unit_shader.CurrentTechnique = unit_shader.Techniques["Tone"]; unit_shader.Parameters["tone"].SetValue(Global.game_map.fow_color.to_vector_4()); } else { fog_color = new Color(168, 168, 168, 255); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, unit_shader); for (int y = 0; y < Data.GetLength(1); y++) { for (int x = 0; x < Data.GetLength(0); x++) { if (Fow[x, y]) { sprite_batch.Draw(Minimap_Texture, new Vector2(x * MINIMAP_TILE_SIZE, y * MINIMAP_TILE_SIZE) + Map_Offset, new Rectangle((Data[x, y] % width) * MINIMAP_TILE_SIZE, (Data[x, y] / width) * MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE), fog_color); } } } sprite_batch.End(); // Visible tiles sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); Color outline_color = new Color(0f, 0f, 0f, 0.5f); byte outline_frame_y, outline_frame_x; bool within_vertical_edges; for (int y = 0; y < Data.GetLength(1); y++) { within_vertical_edges = y + 1 >= Global.game_map.edge_offset_top && y <= Data.GetLength(1) - Global.game_map.edge_offset_bottom; if (y + 1 == Global.game_map.edge_offset_top) { outline_frame_y = 0; } else if (y == Data.GetLength(1) - Global.game_map.edge_offset_bottom) { outline_frame_y = 2; } else { outline_frame_y = 1; } for (int x = 0; x < Data.GetLength(0); x++) { // Draw tile if (!Fow[x, y]) { sprite_batch.Draw(Minimap_Texture, new Vector2(x * MINIMAP_TILE_SIZE, y * MINIMAP_TILE_SIZE) + Map_Offset, new Rectangle((Data[x, y] % width) * MINIMAP_TILE_SIZE, (Data[x, y] / width) * MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE), Color.White); } // Draw attack range if (Attack_Range[x, y] != Minimap_Attack_Range.None) { // Using null for the src rect, make sure that's fine if (Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Staff_All) || Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Staff)) { sprite_batch.Draw(Global.Content.Load <Texture2D>(@"Graphics/White_Square"), new Vector2(x * MINIMAP_TILE_SIZE, y * MINIMAP_TILE_SIZE) + Map_Offset, null, Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Staff) ? new Color(32, 96, 32, 128) : new Color(32, 64, 64, 128), 0f, Vector2.Zero, MINIMAP_TILE_SIZE / 16f, SpriteEffects.None, 0f); } if (Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Attack_All) || Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Attack)) { sprite_batch.Draw(Global.Content.Load <Texture2D>(@"Graphics/White_Square"), new Vector2(x * MINIMAP_TILE_SIZE, y * MINIMAP_TILE_SIZE) + Map_Offset, null, Attack_Range[x, y].HasEnumFlag(Minimap_Attack_Range.Attack) ? new Color(96, 32, 32, 128) : new Color(64, 32, 64, 128), 0f, Vector2.Zero, MINIMAP_TILE_SIZE / 16f, SpriteEffects.None, 0f); } } // Draw playable edge if (within_vertical_edges && x + 1 >= Global.game_map.edge_offset_left && x <= Data.GetLength(0) - Global.game_map.edge_offset_right) { if (x + 1 == Global.game_map.edge_offset_left) { outline_frame_x = 0; } else if (x == Data.GetLength(0) - Global.game_map.edge_offset_right) { outline_frame_x = 2; } else { outline_frame_x = 1; } if (outline_frame_x != 1 || outline_frame_y != 1) { sprite_batch.Draw(Sprite_Texture, new Vector2(x * MINIMAP_TILE_SIZE, y * MINIMAP_TILE_SIZE) + Map_Offset, new Rectangle(outline_frame_x * MINIMAP_TILE_SIZE, 20 + outline_frame_y * MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE, MINIMAP_TILE_SIZE), outline_color); } } } } sprite_batch.End(); } }
public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2)) { Vector2 offset = this.offset; // Bg if (Bg_Texture != null) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); sprite_batch.Draw(Bg_Texture, loc + draw_vector() - draw_offset, Bg_Rect, tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); sprite_batch.End(); } // Face if (Has_Palette) { Effect effect = Global.effect_shader(); if (effect != null) { Texture2D palette_texture = Global.palette_pool.get_palette(); palette_texture.SetData <Color>(Palette); #if __ANDROID__ // There has to be a way to do this for both effect.Parameters["Palette"].SetValue(palette_texture); #else sprite_batch.GraphicsDevice.Textures[2] = palette_texture; #endif sprite_batch.GraphicsDevice.SamplerStates[2] = SamplerState.PointClamp; effect.CurrentTechnique = effect.Techniques["Palette1"]; effect.Parameters["color_shift"].SetValue(new Vector4(0, 0, 0, 0)); effect.Parameters["opacity"].SetValue(1f); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, effect); } else { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); } base.draw(sprite_batch, draw_offset); sprite_batch.End(); #if __ANDROID__ // There has to be a way to do this for both if (Global.effect_shader() != null) { Global.effect_shader().Parameters["Palette"].SetValue((Texture2D)null); } #else sprite_batch.GraphicsDevice.Textures[2] = null; #endif // Flags if (Flag_Texture != null) { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); sprite_batch.Draw(Flag_Texture, loc + draw_vector() - draw_offset, Flag_Rect, tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); sprite_batch.End(); } }
protected IEnumerable <BattlerRenderCommands> draw_battlers(SpriteBatch sprite_batch, Tuple <Battler_Sprite, bool> active_battler_sprite, IEnumerable <Tuple <Battler_Sprite, bool> > inactive_battler_sprites) { Effect battle_shader = Global.effect_shader(); // Draw avoiding targets on the bottom if (inactive_battler_sprites != null) { foreach (var battler in inactive_battler_sprites) { if (battler.Item1.avoiding) { Vector2 shake = battler.Item2 ? P2Shake : P1Shake; foreach (BattlerRenderCommands command in battler.Item1.draw_lower(sprite_batch, shake, battle_shader)) { yield return(command); } } } } // Draw active battler lower frames if (active_battler_sprite != null) { Vector2 shake = active_battler_sprite.Item2 ? P2Shake : P1Shake; foreach (BattlerRenderCommands command in active_battler_sprite.Item1.draw_lower(sprite_batch, shake, battle_shader)) { yield return(command); } } // Draw targets in the middle if (inactive_battler_sprites != null) { foreach (var battler in inactive_battler_sprites) { if (!battler.Item1.avoiding) { Vector2 shake = battler.Item2 ? P2Shake : P1Shake; foreach (BattlerRenderCommands command in battler.Item1.draw_lower(sprite_batch, shake, battle_shader)) { yield return(command); } foreach (BattlerRenderCommands command in battler.Item1.draw_upper(sprite_batch, shake, battle_shader)) { yield return(command); } } } } // Draw active battler lower frames if (active_battler_sprite != null) { Vector2 shake = active_battler_sprite.Item2 ? P2Shake : P1Shake; foreach (BattlerRenderCommands command in active_battler_sprite.Item1.draw_upper(sprite_batch, shake, battle_shader)) { yield return(command); } } // Draw avoiding targets on the top if (inactive_battler_sprites != null) { foreach (var battler in inactive_battler_sprites) { if (battler.Item1.avoiding) { Vector2 shake = battler.Item2 ? P2Shake : P1Shake; foreach (BattlerRenderCommands command in battler.Item1.draw_upper(sprite_batch, shake, battle_shader)) { yield return(command); } } } } yield return(BattlerRenderCommands.Finish); }
public void draw( SpriteBatch sprite_batch, Vector2 draw_offset, Maybe <Rectangle> scissorRect) { if (texture != null) { if (visible) { // If clipping RasterizerState scissorState = null; if (scissorRect.IsSomething) { scissorState = new RasterizerState { ScissorTestEnable = true }; sprite_batch.GraphicsDevice.ScissorRectangle = Scene_Map.fix_rect_to_screen(scissorRect); } // Adjust position if (Convo_Placement_Offset) { draw_offset -= new Vector2(placement_offset * (mirrored ? 1 : -1), 0); } // Setup shader for palettes if (palette_exists) { Effect effect = Global.effect_shader(); if (effect != null) { Texture2D palette_texture = Global.palette_pool.get_palette(); palette_texture.SetData <Color>(Palette); #if __ANDROID__ // There has to be a way to do this for both effect.Parameters["Palette"].SetValue(palette_texture); #else sprite_batch.GraphicsDevice.Textures[2] = palette_texture; #endif sprite_batch.GraphicsDevice.SamplerStates[2] = SamplerState.PointClamp; effect.CurrentTechnique = effect.Techniques["Palette1"]; effect.Parameters["color_shift"].SetValue(new Vector4(0, 0, 0, 0)); effect.Parameters["opacity"].SetValue(1f); } sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, scissorState, effect); } else { sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, scissorState); } Rectangle src_rect = this.src_rect; Vector2 offset = this.offset; if (mirrored) { offset.X = src_rect.Width - offset.X; } // Crop eyes and mouth out of body, then draw it foreach (var rect in frame_exclusion()) { Vector2 frame_offset = new Vector2( rect.X - src_rect.X, rect.Y - src_rect.Y); frame_offset = new Vector2(mirrored ? this.FaceWidth - (frame_offset.X + (int)rect.Width) : frame_offset.X, frame_offset.Y); sprite_batch.Draw(texture, this.loc + frame_offset + draw_vector() - draw_offset, rect, tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); } int eyes_frame = Idle ? 0 : EyesFrame; int mouth_frame = Idle ? 0 : MouthFrame; // Eyes sprite_batch.Draw(texture, Loc + Eyes_Loc + draw_vector() - draw_offset, eyes_rect(eyes_frame), tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); // Mouth sprite_batch.Draw(texture, Loc + Mouth_Loc + draw_vector() - draw_offset, mouth_rect(mouth_frame), tint, angle, offset, scale, mirrored ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Z); sprite_batch.End(); #if __ANDROID__ // There has to be a way to do this for both if (Global.effect_shader() != null) { Global.effect_shader().Parameters["Palette"].SetValue((Texture2D)null); } #else sprite_batch.GraphicsDevice.Textures[2] = null; #endif } } }