private void refresh_label_hue(Game_Unit unit) { if (LabelHueFormula != null) { LabelTint = LabelHueFormula(unit); } }
public override void set_images(bool player_called) { if (player_called) { if (map_check() != Map_Info_State.Onscreen) { return; } } Game_Unit unit = get_unit; bool valid_unit = unit != null && unit.visible_by(); if (valid_unit && Enemy_Info) { var selected_unit = Global.game_map.get_selected_unit(); if (selected_unit == null) { valid_unit &= !unit.is_player_allied; } else { valid_unit &= unit.is_attackable_team(selected_unit); } } if (valid_unit) { move_on(); // This needs to come on somewhere else, it doesn't care about move list count currently //Yeti draw_images(unit); } else { move_off(); } }
protected void set_animation_mode(int id1, int id2, bool fighting, Combat_Data data) { bool scene_battle = is_scene_battle(id1, id2, fighting, data); // If not using map battle mode, ensure battlers actually have sprites for scene battle mode if (scene_battle) { foreach (int id in new int[] { id1, id2 }) { if (!Units.ContainsKey(id)) { scene_battle = false; break; } Game_Unit unit = Units[id]; var battlerData = new BattlerSpriteData(unit); if (!battlerData.AnimData(Global.game_state.dance_active && id == id1).ValidAnim) { scene_battle = false; break; } } } Global.game_system.Battle_Mode = scene_battle ? Constants.Animation_Modes.Full : Constants.Animation_Modes.Map; }
protected int set_base_index(List <int> Targets) { // Healing if (Mode == Staff_Target_Mode.Heal) { float min_hp = 1f; int index = 0; for (int i = 0; i < Targets.Count; i++) { int id = Targets[i]; Game_Unit target = Global.game_map.units[id]; float percent = target.actor.hp / (float)target.actor.maxhp; if (percent <= min_hp) { index = i; min_hp = percent; } } return(index); } else { return(0); } }
internal int avo(Game_Unit target, bool staff = false, WeaponTriangle tri = WeaponTriangle.Nothing) { int actor_avo, bonus = 0, skill_avo; // Terrain avoid bonus if (Global.scene.is_map_scene) { bool magic_attack = target != null && target.check_magic_attack(target.actor.weapon, Distance); var terrain_bonus = attacker.terrain_avo_bonus(target, magic_attack); if (terrain_bonus.IsSomething) { bonus += terrain_bonus; } } if (staff) { actor_avo = res() * 5; bonus += Distance * 2; } else { actor_avo = base_avo(); } skill_avo = 0; attacker.avo_skill(ref skill_avo, ref actor_avo, ref bonus, attacker_weapon, target, tri); // Support avoid bonus bonus += support_bonus(Combat_Stat_Labels.Avo); return(Math.Max(0, actor_avo + bonus + skill_avo)); }
public Window_Target_Staff(int unit_id, int item_index, Vector2 loc) { initialize(loc); Unit_Id = unit_id; var staff = Global.data_weapons[get_unit().actor.items[item_index].Id]; Mode = target_mode(staff); if (staff.Torch()) { Manual_Targeting = true; } Right_X = Config.WINDOW_WIDTH - this.window_width; List <int> targets = get_targets(item_index); Targets = sort_targets(targets); this.index = set_base_index(Targets); Temp_Index = this.index; if (Targets.Count > 0) { Game_Unit target = Global.game_map.units[this.target]; cursor_move_to(target); } Global.player.instant_move = true; Global.player.update_movement(); initialize_images(); refresh(); index = this.index; }
protected void process_animation_frame(Game_Unit unit, int frame) { // Change image if (Animation.data[frame].Change_Image) { if (unit != null) { unit.refresh_sprite(unit.actual_map_sprite_name + Animation.data[frame].Image_Name, Animation.data[frame].Moving); } #if DEBUG else { throw new NotImplementedException("Map object animation isn't set up for not-units yet"); } #endif if ((int)Animation.data[frame].Image_Cells.X != 0 && (int)Animation.data[frame].Image_Cells.Y != 0) { facing_count = (int)Animation.data[frame].Image_Cells.Y; frame_count = (int)Animation.data[frame].Image_Cells.X; offset = new Vector2( (texture.Width / frame_count) / 2, Math.Min((texture.Height / facing_count), (texture.Height / (facing_count * 2)) + 20)); } } this.frame = Animation.data[frame].Frame_Index; }
protected override void set_name(Game_Unit unit) { Name.text = unit.actor.name; Name.offset = new Vector2(unit.is_active_player_team ? -16 : 0, 0); //Multi Inventory.set_images(unit); Stats.set_images(unit); }
protected override List <int> sort_targets(List <int> targets) { Game_Unit unit = get_unit(); targets.Sort(delegate(int a, int b) { Vector2 loc1, loc2; int dist1, dist2; if (mode == 1) { loc1 = new Vector2(a % Global.game_map.width, a / Global.game_map.width); loc2 = new Vector2(b % Global.game_map.width, b / Global.game_map.width); dist1 = (int)(Math.Abs(unit.loc.X - loc1.X) + Math.Abs(unit.loc.Y - loc1.Y)); dist2 = (int)(Math.Abs(unit.loc.X - loc2.X) + Math.Abs(unit.loc.Y - loc2.Y)); } else { Game_Unit unit1 = Global.game_map.units[a]; Game_Unit unit2 = Global.game_map.units[b]; loc1 = unit1.loc_on_map(); loc2 = unit2.loc_on_map(); dist1 = Global.game_map.unit_distance(Unit_Id, a); dist2 = Global.game_map.unit_distance(Unit_Id, b); } int angle1 = ((360 - unit.angle(loc1)) + 90) % 360; int angle2 = ((360 - unit.angle(loc2)) + 90) % 360; return(angle1 == angle2 ? (loc1.Y == loc2.Y ? dist1 - dist2 : (int)(loc1.Y - loc2.Y)) : angle1 - angle2); }); return(targets); }
protected override void set_name(Game_Unit unit) { Name.text = unit.actor.name; Name.offset = new Vector2(24, 0); //Inventory.set_images(unit); Stats.set_images(unit); }
protected override void set_images() { Game_Unit target = Global.game_map.units[this.target]; Window.rows = Math.Max(1, target.actor.num_items); Items.Clear(); for (int i = 0; i < Math.Max(1, target.actor.num_items); i++) { draw_item(target, i); } // Sets Name // Name.text = target.actor.name; // Map Sprite // if (target.is_rescued) { Rescue_Icon.visible = true; Rescue_Icon.src_rect = new Rectangle( (target.team - 1) * (Rescue_Icon.texture.Width / Constants.Team.NUM_TEAMS), 0, Rescue_Icon.texture.Width / Constants.Team.NUM_TEAMS, Rescue_Icon.texture.Height); Target_Sprite.texture = null; } else { Rescue_Icon.visible = false; Target_Sprite.texture = Scene_Map.get_team_map_sprite(target.team, target.map_sprite_name); Target_Sprite.offset = new Vector2( (Target_Sprite.texture.Width / Target_Sprite.frame_count) / 2, (Target_Sprite.texture.Height / Target_Sprite.facing_count) - 8); Target_Sprite.mirrored = target.has_flipped_map_sprite; } refresh(); }
protected void color_text(Game_Unit unit, TactileLibrary.Item_Data item_data, List <string> strs) { for (int i = 0; i < num_items(); i++) { string color = "Green"; // Equip if (Index_Redirect[i] == 0 && !unit.actor.is_equippable(Global.data_weapons[item_data.Id])) { color = "Grey"; } // Use else if (Index_Redirect[i] == 1) { if (Combat.can_use_item(unit, item_data.Id, item_data.is_weapon)) { color = "White"; } else { color = "Grey"; } } // Discard else if (Index_Redirect[i] == 3 && !Can_Discard) { color = "Grey"; } Items[i].set_text_color(color); } }
public void set_images(Game_Unit unit) { Game_Actor actor = unit.actor; // Stats switch (actor.power_type()) { case Power_Types.Strength: PowNode.set_label("Str"); break; case Power_Types.Magic: PowNode.set_label("Mag"); break; default: PowNode.set_label("Pow"); break; } // Refresh UI nodes foreach (StatusUINode node in Stats) { node.refresh(unit); } }
internal override void refresh(Game_Unit unit) { PrimaryStatState stat = StatFormula == null ? new PrimaryStatState() : stat = StatFormula(unit); if (stat.NullStat) { Text.text = "--"; } else { Text.text = stat.Stat.ToString(); } Text.SetColor(Global.Content, stat.IsCapped ? "Green" : "Blue"); Bonus.text = stat.Bonus == 0 ? "" : string.Format( "{0}{1}", stat.Bonus > 0 ? "+" : "", stat.Bonus); Bonus.SetColor(Global.Content, stat.Bonus > 0 ? "Green" : "Red"); PenaltyArrow.value = stat.Penalized ? WeaponTriangle.Disadvantage : WeaponTriangle.Nothing; refresh_bar(stat.Stat, stat.Bonus, stat.Cap); refresh_label_hue(unit); }
protected override void set_pages() { for (int i = 0; i < Team.Count; i++) { Game_Unit unit = Global.game_map.units[Team[i]]; Game_Actor actor = unit.actor; int y = i * Y_Per_Row; // Add map sprite Map_Sprites.Add(new Character_Sprite()); Map_Sprites[i].facing_count = 3; Map_Sprites[i].frame_count = 3; Map_Sprites[i].texture = Scene_Map.get_team_map_sprite(unit.team, unit.map_sprite_name); Map_Sprites[i].offset = new Vector2( (Map_Sprites[i].texture.Width / Map_Sprites[i].frame_count) / 2, (Map_Sprites[i].texture.Height / Map_Sprites[i].facing_count) - 8); Map_Sprites[i].loc = new Vector2(32, y + 16 + Offset_Y) + new Vector2(Unit_Scissor_Rect.X, Unit_Scissor_Rect.Y); Map_Sprites[i].stereoscopic = Config.UNIT_WINDOW_DEPTH; Map_Sprites[i].mirrored = unit.has_flipped_map_sprite; // Name Names.Add(new TextSprite()); Names[i].loc = new Vector2(40, y + Offset_Y) + new Vector2(Unit_Scissor_Rect.X, Unit_Scissor_Rect.Y); Names[i].SetFont(Config.UI_FONT, Global.Content, "White"); Names[i].text = unit.actor.name; Names[i].stereoscopic = Config.UNIT_WINDOW_DEPTH; // Page 1 Page_Imgs[0].Add(new SoloAnim_Page(unit)); Page_Imgs[0][i].loc = new Vector2(data_width * 0, y + Offset_Y) + new Vector2(Data_Scissor_Rect.X, Data_Scissor_Rect.Y); } }
public virtual void set_images(bool player_called) { if (player_called) { if (map_check() != Map_Info_State.Onscreen) { return; } } Game_Unit unit = get_unit; if (unit != null && unit.visible_by()) { if (!update_position_switch()) { if (Offscreen) { move_on(); // This needs to come on somewhere else, it doesn't care about move list count currently //Yeti } draw_images(unit); } } else { // Switching vertical positions will handle moving off, so only move off if it doesn't happen if (!update_position_switch()) { move_off(); } } }
private bool team_passable(Game_Unit unit, Vector2 loc) { if (!UnitLocs.Keys.Contains(loc)) { return(true); } return(UnitLocs[loc] != Unit_Passable.Blocked); }
internal void set_animation(Game_Unit unit, Map_Unit_Animation_Data animation) { Animation = animation; Animation_Frame = 0; Animation_Frame_Timer = 0; Animation_Total_Time = 0; process_animation_frame(unit); }
internal override void refresh(Game_Unit unit) { base.refresh(unit); if (AidTypeFormula != null) { Aid_Icon.index = AidTypeFormula(unit); } }
private int hit_target(Game_Unit target) { Data_Weapon weapon = this.attacker_weapon; // Checks if weapon is magic bool magic_attack = attacker.check_magic_attack(weapon, Distance); bool is_staff = weapon.is_staff(); Game_Actor actor2 = target.actor; Data_Weapon weapon2 = actor2.weapon; bool boss_staff = false; int actor_hit, weapon_hit, skill_hit, support_hit, s_bonus; int hit_rate, target_avo; if (is_staff) { actor_hit = attacker.atk_pow(weapon, magic_attack) * 5 + attacker.stat(Stat_Labels.Skl); weapon_hit = weapon.Hit; skill_hit = 0; attacker.hit_skill( ref skill_hit, ref weapon_hit, ref actor_hit, weapon, target, magic_attack, Distance); support_hit = support_bonus(Combat_Stat_Labels.Hit); s_bonus = 0; hit_rate = Math.Max(0, actor_hit + weapon_hit + skill_hit + support_hit + s_bonus); target_avo = this.target_stats().staff_avo(); boss_staff = target.boss; } else { actor_hit = base_hit(weapon, magic_attack); weapon_hit = weapon.Hit; skill_hit = 0; attacker.hit_skill( ref skill_hit, ref weapon_hit, ref actor_hit, weapon, target, magic_attack, Distance); support_hit = support_bonus(Combat_Stat_Labels.Hit); s_bonus = attacker.actor.s_rank_bonus(weapon); // Weapon triangle WeaponTriangle tri = Combat.weapon_triangle(attacker, target, weapon, weapon2, Distance); if (tri != WeaponTriangle.Nothing) { weapon_hit += Weapon_Triangle.HIT_BONUS * (tri == WeaponTriangle.Advantage ? 1 : -1) * Combat.weapon_triangle_mult(attacker, target, weapon, weapon2, Distance); } hit_rate = Math.Max(0, actor_hit + weapon_hit + skill_hit + support_hit + s_bonus); target_avo = this.target_stats().avo(Combat.reverse_wta(tri)); } int total_hit = hit_rate - target_avo; int result = attacker.hit_target_skill( target, weapon, Distance, Math.Max(total_hit, 0) / (boss_staff ? 2 : 1)); return(result); }
internal Combat_Metrics(int turn, CombatTypes type, Game_Unit attacker, int attacker_hp, int weapon_1_id, int attacker_attacks, List <Combat_Map_Object> targets, List <int> target_hps, List <int> weapon_2_ids, List <int> targets_attacks) { Turn = turn; CombatType = type.ToString(); Attacker = new Combatant_Metric(attacker, attacker_hp, weapon_1_id, attacker_attacks); Targets = targets == null ? new List <Combatant_Metric>() : Enumerable.Range(0, targets.Count) .Select(x => new Combatant_Metric(targets[x], target_hps[x], weapon_2_ids[x], targets_attacks[x])).ToList(); }
protected override void draw_images(Game_Unit unit) { Window_Img.team = unit.team; // Name set_name(unit); // HP Hp_Gauge.set_val(unit.actor.hp, unit.actor.maxhp); Exp_Gauge.set_val(unit.actor.exp, unit.actor.level, !(unit.is_active_player_team && unit.actor.can_level())); //Multi }
private void refresh_equippable(Game_Unit unit, Data_Weapon weapon) { string color = unit.actor.is_equippable(weapon) ? "Blue" : "Grey"; foreach (var stat in Stats) { stat.SetColor(Global.Content, color); } }
protected bool update_aoe_cleanup_actions(Game_Unit Battler_1) { switch (Cleanup_Action[0][0]) { case (int)Cleanup_Actions.Item_Gain: switch (Combat_Timer) { case 0: Combat_Timer++; Game_Unit item_receiver = Cleanup_Action[0][1] == 1 ? Battler_1 : Units[Aoe_Targets[Cleanup_Action[0][2] * -1]]; Game_Unit item_giver = Cleanup_Action[0][1] == 1 ? Units[Aoe_Targets[Cleanup_Action[0][2]]] : Battler_1; if (item_receiver.can_acquire_drops) { Global.game_system.play_se(System_Sounds.Gain); TactileLibrary.Item_Data item_data = item_giver.actor.drop_item(); if (Constants.Gameplay.REPAIR_DROPPED_ITEM) { item_data.repair(); } item_receiver.actor.gain_item(item_data); get_scene_map().set_item_popup(item_data, 113); if (item_receiver.actor.too_many_items) { Global.game_temp.menu_call = true; Global.game_temp.discard_menu_call = true; Global.game_system.Discarder_Id = item_receiver.id; } } else { Combat_Timer = 0; Cleanup_Action.RemoveAt(0); return(false); } break; case 1: if (!Global.game_temp.menu_call && !Global.game_state.is_menuing && !get_scene_map().is_map_popup_active()) { Combat_Timer++; } break; case 21: Cleanup_Action.RemoveAt(0); Combat_Timer = 0; break; default: Combat_Timer++; break; } return(true); } return(update_cleanup_actions(Battler_1, null)); }
internal virtual void cheat(Game_Unit unit, DirectionFlags dir) { if (Cheat != null) { if (Cheat(unit, dir)) { Global.game_system.play_se(System_Sounds.Menu_Move2); } } }
protected override void reset_cursor() { if (Manual_Targeting) { return; } Game_Unit target = Global.game_map.units[Targets[Temp_Index]]; cursor_move_to(target); }
internal PrimaryStatState(Game_Unit unit, Stat_Labels stat_label) { Stat = unit.stat(stat_label) - unit.stat_bonus(stat_label); Bonus = unit.stat_bonus_display(stat_label); Cap = unit.stat_cap(stat_label); IsCapped = unit.actor.get_capped(stat_label); Penalized = unit.is_weighed_stat(stat_label); NullStat = false; }
public WindowItemManagement(Game_Unit unit) { Unit_Id = unit.id; initialize_sprites(); refresh_input_help(); refresh(); update_black_screen(); }
public Item_Metrics(int turn, Game_Unit unit, Item_Data item_data) { Turn = turn; Team = unit.team; ActorId = unit.actor.id; ClassId = unit.actor.class_id; ItemData = item_data; ItemName = item_data.to_equipment.full_name(); Loc = unit.loc; }
private void refugeTargetMenu_Selected(object sender, EventArgs e) { Global.game_system.play_se(System_Sounds.Confirm); var targetMenu = (sender as UnitTargetMenu); targetMenu.Accept(); Game_Unit unit = Global.game_map.units[targetMenu.UnitId]; MenuHandler.UnitMenuRefuge(unit, targetMenu.SelectedUnitId); }