public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2)) { //if ((textures.Count == 3) && Global.game_map.units.ContainsKey(Data.Battler_1_Id)) if ((textures.Count == 3) && unit_1 != null) { if (visible) { Vector2 loc = this.loc + new Vector2(0, Data == null ? 8 : 0); Vector2 offset = this.offset; int width; bool two_units = false; if (unit_2 != null) { if (Global.game_map.attackable_map_object(battler_2_id) != null) { two_units = true; } } // Window 1 - top sprite_batch.Draw(textures[0], loc + new Vector2(1, 0), new Rectangle(0, 64 * (team1 - 1), 88, 32), tint, 0f, offset + Window_Offset, 1f, SpriteEffects.None, 0f); // HP gauge 1 sprite_batch.Draw(textures[0], loc + new Vector2(24, 16), new Rectangle(88, 0, 56, 8), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); width = (Hp1 * 49) / maxhp1; sprite_batch.Draw(textures[0], loc + new Vector2(24 + 4, 16), new Rectangle(88 + 4, 8, width, 8), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); if (Data != null) { // Window 1 - bottom sprite_batch.Draw(textures[0], loc + new Vector2(1, 24), new Rectangle(0, 64 * (team1 - 1) + 32, 88, 32), tint, 0f, offset + Window_Offset, 1f, SpriteEffects.None, 0f); // Labels 1 sprite_batch.Draw(textures[0], loc + new Vector2(4, 28), new Rectangle(88, 16, 56, 16), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); // Stats 1 for (int i = 0; i < 4; i++) { Stat_Imgs[i].loc = loc + new Vector2(42, 28); Stat_Imgs[i].draw(sprite_batch, Data_Offset); } } // Name 1 Name1.loc = loc + new Vector2(44, 0); Name1.draw(sprite_batch, Data_Offset); // HP 1 HP_Counter1.loc = loc + new Vector2(24, 16); HP_Counter1.draw(sprite_batch, Data_Offset); if (two_units) { loc += new Vector2(88, 0); // Window 2 - top sprite_batch.Draw(textures[0], loc + new Vector2(0, 0), new Rectangle(0, 64 * (team2 - 1), 88, 32), tint, 0f, offset + Window_Offset, 1f, SpriteEffects.None, 0f); // HP Gauge 2 sprite_batch.Draw(textures[0], loc + new Vector2(24, 16), new Rectangle(88, 0, 56, 8), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); width = (Hp2 * 49) / maxhp2; sprite_batch.Draw(textures[0], loc + new Vector2(24 + 4, 16), new Rectangle(88 + 4, 8, width, 8), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); if (Data != null) { // Window 2 - bottom sprite_batch.Draw(textures[0], loc + new Vector2(0, 24), new Rectangle(0, 64 * (team2 - 1) + 32, 88, 32), tint, 0f, offset + Window_Offset, 1f, SpriteEffects.None, 0f); // Labels 2 sprite_batch.Draw(textures[0], loc + new Vector2(4, 28), new Rectangle(88, 16, 56, 16), tint, 0f, offset + Data_Offset, 1f, SpriteEffects.None, 0f); // Stats 2 for (int i = 4; i < 8; i++) { Stat_Imgs[i].loc = loc + new Vector2(42, 28); Stat_Imgs[i].draw(sprite_batch, Data_Offset); } } // Name 2 Name2.loc = loc + new Vector2(44, 0); Name2.draw(sprite_batch, Data_Offset); // HP 2 HP_Counter2.loc = loc + new Vector2(24, 16); HP_Counter2.draw(sprite_batch, Data_Offset); } } } }
public override void update() { if (Window_Shake.Count > 0) { Window_Offset = Window_Shake.shift(); } if (Data_Shake.Count > 0) { Data_Offset = Data_Shake.shift(); } if (Timer < TIMER_MAX) { Timer++; } if (Hp1 != this.hp1 || (unit_2 != null && Hp2 != this.hp2)) { if (Global.Input.triggered(Inputs.A) || Global.Input.mouse_triggered(MouseButtons.Left) || Global.Input.gesture_triggered(TouchGestures.Tap)) { if (Hp1 < this.hp1 || (unit_2 != null && Hp2 < this.hp2)) { Global.game_system.play_se(System_Sounds.HP_Recovery); } Hp1 = this.hp1; if (unit_2 != null) { Hp2 = this.hp2; } } } if (Hp1_Timer == 0) { if (Hp1 < hp1) { Global.game_system.play_se(System_Sounds.HP_Recovery); Hp1_Timer = HP_GAIN_TIME; } Hp1 = Additional_Math.int_closer(Hp1, hp1, 1); } if (unit_2 != null && Hp2_Timer == 0) { if (Hp2 < hp2) { Global.game_system.play_se(System_Sounds.HP_Recovery); Hp2_Timer = HP_GAIN_TIME; } Hp2 = Additional_Math.int_closer(Hp2, hp2, 1); } if (Hp1_Timer > 0) { Hp1_Timer--; } if (Hp2_Timer > 0) { Hp2_Timer--; } Name1.update(); HP_Counter1.text = (Hp1 > 99 ? "??" : Hp1.ToString()); HP_Counter1.update(); if (unit_2 != null) { Name2.update(); HP_Counter2.text = (Hp2 > 99 ? "??" : Hp2.ToString()); HP_Counter2.update(); } // Update stats if (!stat_update_done()) { if (Stat_Timer == 0) { update_stats(); refresh_battle_stats(); Stat_Timer = 2; } } if (Stat_Timer > 0) { Stat_Timer--; } foreach (RightAdjustedText text in Stat_Imgs) { text.update(); } }