protected virtual void attacker_target_unit(Combat_Map_Object target)
 {
     if (target.is_unit())
     {
         ((Game_Unit)target).target_unit(
             get_unit(), get_unit().actor.weapon, Global.game_map.combat_distance(Unit_Id, ((Game_Unit)target).id));
     }
 }
        internal override Vector2 target_loc(int target)
        {
            // Drop
            if (mode == 1)
            {
                return(new Vector2(target % Global.game_map.width, target / Global.game_map.width));
            }

            Combat_Map_Object unit1 = Global.game_map.attackable_map_object(target);

            return(unit1.loc_on_map());
        }
 public Combatant_Metric(Combat_Map_Object map_object, int start_hp, int weapon_id, int attack_count) : this()
 {
     Team       = map_object is Game_Unit ? (map_object as Game_Unit).team : -1;
     ActorId    = map_object is Game_Unit ? (map_object as Game_Unit).actor.id : map_object.id;
     ClassId    = map_object is Game_Unit ? (map_object as Game_Unit).actor.class_id : -1;
     StartHp    = start_hp;
     EndHp      = map_object.hp;
     WeaponId   = weapon_id;
     WeaponName = Global.data_weapons.ContainsKey(weapon_id) ? Global.data_weapons[weapon_id].full_name() : "-----";
     Attacks    = attack_count;
     Loc        = map_object.loc;
 }
Beispiel #4
0
        internal int unit_distance(int id1, int id2)
        {
            Game_Unit unit1 = Units[id1];

            if (unit1.is_rescued)
            {
                unit1 = Units[unit1.rescued];
            }
            Combat_Map_Object unit2 = attackable_map_object(id2);

            if (unit2.is_unit() && ((Game_Unit)unit2).is_rescued)
            {
                unit2 = Units[((Game_Unit)unit2).rescued];
            }
            return((int)(Math.Abs(unit1.loc.X - unit2.loc.X) + Math.Abs(unit1.loc.Y - unit2.loc.Y)));
        }
        protected virtual void InitialTarget(int index = 0)
        {
            this.index = index;
            Temp_Index = this.index;

            Combat_Map_Object target =
                Global.game_map.attackable_map_object(this.target);

#if DEBUG
            if (target == null)
            {
                throw new IndexOutOfRangeException("No combat targets found");
            }
#endif
            attacker_target_unit(target);
            cursor_move_to(target);
            Global.player.instant_move = true;
            Global.player.update_movement();
            initialize_images();
            refresh();
        }
Beispiel #6
0
        protected override void set_images()
        {
            base.set_images();

            Game_Unit         unit        = get_unit();
            Combat_Map_Object target      = Global.game_map.attackable_map_object(this.target);
            Game_Unit         target_unit = null;
            bool is_target_unit           = false;

            if (target.is_unit())
            {
                is_target_unit = true;
                target_unit    = (Game_Unit)target;
            }
            int distance = Global.game_map.combat_distance(unit.id, this.target);

            // Get weapon data
            TactileLibrary.Data_Weapon weapon1 = unit.actor.weapon, weapon2 = null;
            if (is_target_unit)
            {
                weapon2 = target_unit.actor.weapon;
            }

            List <int?> combat_stats = Combat.combat_stats(unit.id, this.target, distance);

            if (this.skills_visible)
            {
                for (int i = base.stat_rows * 2; i < stat_rows * 2; i++)
                {
                    if (is_target_unit &&
                        combat_stats[(i % 2) * 4 + 3] == null &&
                        (i % 2 == 0 ? unit.shown_skill_rate(target_unit) : target_unit.shown_skill_rate(unit)) == null &&
                        (i % 2 == 0 ? unit : target_unit).has_any_mastery() != null)
                    {
                        Mastery_Gauge gauge = new Mastery_Gauge((i % 2 == 0 ? unit : target_unit).any_mastery_charge_percent());
                        gauge.height = 4;
                        Stats.Add(gauge);
                        gauge.draw_offset = new Vector2(
                            48 + 4 - (48 * (i % 2)),
                            0 + ((i / 2 + 1) * LINE_HEIGHT));
                    }
                    else
                    {
                        RightAdjustedText text = new RightAdjustedText();
                        Stats.Add(text);
                        text.draw_offset = new Vector2(68 - (48 * (i % 2)), 4 + ((i / 2 + 1) * LINE_HEIGHT));
                        text.SetFont(Config.UI_FONT, Global.Content, "Blue");
                        text.text = "0";
                    }
                }

                // Sets first units's stats //
                // Skill
                if (!(is_target_unit && combat_stats[3] == null && unit.shown_skill_rate(target_unit) == null && unit.has_any_mastery() != null))
                {
                    ((RightAdjustedText)Stats[base.stat_rows * 2]).text = combat_stats[3] == null ? "--" : combat_stats[3].ToString();
                }

                // Sets second units's stats //
                if (!is_target_unit || !(combat_stats[7] == null && target_unit.shown_skill_rate(unit) == null && target_unit.has_any_mastery() != null))
                {
                    // Skill
                    if (is_target_unit && can_counter(unit, target_unit, weapon1, distance))
                    {
                        ((RightAdjustedText)Stats[base.stat_rows * 2 + 1]).text = combat_stats[7] == null ? "--" : combat_stats[7].ToString();
                    }
                    else
                    {
                        ((RightAdjustedText)Stats[base.stat_rows * 2 + 1]).text = "--";
                    }
                }
            }

            for (int i = 0; i < 4; i++)
            {
                RightAdjustedText text = new RightAdjustedText();
                Stats.Add(text);
                text.offset = new Vector2(-(69 - (48 * (i / 2))),
                                          -(5 + ((i % 2 + 1) * (LINE_HEIGHT / 2)) + ((Window.rows - 1) * LINE_HEIGHT)));
                text.SetFont(Config.UI_FONT + "S", Global.Content, "Blue", Config.UI_FONT);
                text.text = "--";
            }
            if (is_target_unit)
            {
                // Terrain def
                bool magic2 = weapon2 == null ? false : target_unit.check_magic_attack(weapon2, distance);
                var  def    = magic2 ? unit.terrain_res_bonus(target_unit) : unit.terrain_def_bonus(target_unit);
                ((RightAdjustedText)Stats[stat_rows * 2]).text = def.IsNothing ? "--" : def.ToString();
                // Terrain avo
                var avo = unit.terrain_avo_bonus(target_unit, magic2);
                ((RightAdjustedText)Stats[stat_rows * 2 + 1]).text = avo.IsNothing ? "--" : avo.ToString();
            }
            if (is_target_unit)
            {
                // Terrain def
                bool magic1 = unit.check_magic_attack(weapon1, distance);
                var  def    = magic1 ? target_unit.terrain_res_bonus(unit) : target_unit.terrain_def_bonus(unit);
                ((RightAdjustedText)Stats[stat_rows * 2 + 2]).text = def.IsNothing ? "--" : def.ToString();
                // Terrain avo
                var avo = target_unit.terrain_avo_bonus(unit, magic1);
                ((RightAdjustedText)Stats[stat_rows * 2 + 3]).text = avo.IsNothing ? "--" : avo.ToString();
            }
            refresh();
        }
        protected override void set_images()
        {
            Icon1.flash = false;
            Icon2.flash = false;
            Mult1.value = 0;
            Mult2.value = 0;
            WTA1.set_effectiveness(1);
            WTA2.set_effectiveness(1);
            Game_Unit         unit   = get_unit();
            Game_Actor        actor1 = unit.actor;
            Combat_Map_Object target =
                Global.game_map.attackable_map_object(this.target);
            Game_Unit  target_unit    = null;
            Game_Actor actor2         = null;
            bool       is_target_unit = false;

            if (target.is_unit())
            {
                is_target_unit = true;
                target_unit    = (Game_Unit)target;
                actor2         = target_unit.actor;
                Window.team2   = target_unit.team;
            }
            else
            {
                Window.team2 = target.team;
            }
            int distance = combat_distance(unit.id, this.target);

            // Get weapon data
            TactileLibrary.Data_Weapon weapon1 = actor1.weapon, weapon2 = null;
            if (is_target_unit)
            {
                weapon2 = actor2.weapon;
            }
            // Weapon triangle arrows
            WTA1.value = 0;
            WTA2.value = 0;
            WeaponTriangle tri = WeaponTriangle.Nothing;

            if (is_target_unit)
            {
                tri = Combat.weapon_triangle(unit, target_unit, weapon1, weapon2, distance);
            }
            if (tri != WeaponTriangle.Nothing)
            {
                WTA1.value = tri;
                if (weapon2 != null)
                {
                    WTA2.value = Combat.reverse_wta(tri);
                }
            }

            List <int?> combat_stats = get_combat_stats(unit.id, this.target, distance);

            Stats = new List <Sprite>();
            for (int i = 0; i < stat_rows * 2; i++)
            {
                RightAdjustedText text = new RightAdjustedText();
                Stats.Add(text);
                text.draw_offset = new Vector2(68 - (48 * (i / 4)), 4 + ((i % 4 + 1) * LINE_HEIGHT));
                text.SetFont(Config.UI_FONT, Global.Content, "Blue");
                text.text = "0";
            }
            // Sets first units's stats //
            Name1.draw_offset = new Vector2(44, 4);
            Name1.text        = actor1.name;
            Name1.offset      = new Vector2(Name1.text_width / 2, 0);
            // Multiplier
            Mult1.value = Mult1.get_multi(unit, target, weapon1, distance);
            // Icon
            Icon1.index   = weapon1.Image_Index;
            Icon1.texture = Global.Content.Load <Texture2D>(@"Graphics/Icons/" + weapon1.Image_Name);
            if (weapon1.effective_multiplier(unit, target_unit) > 1)
            {
                Icon1.flash = true;
            }
            float effectiveness = weapon1.effective_multiplier(unit, target_unit, false);

            WTA1.set_effectiveness((int)effectiveness,
                                   is_target_unit && target_unit.halve_effectiveness());
            // Hp
            if (actor1.hp >= Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
            {
                ((RightAdjustedText)Stats[0]).text = "--";
            }
            else
            {
                ((RightAdjustedText)Stats[0]).text = actor1.hp.ToString();
            }
            // Dmg
            ((RightAdjustedText)Stats[1]).text = combat_stats[1].ToString();
            // Hit
            if (combat_stats[0] >= 100)
            {
                ((RightAdjustedText)Stats[2]).SetFont("Blue_100", Global.Content);
            }
            ((RightAdjustedText)Stats[2]).text = combat_stats[0].ToString();
            // Crt
            if (combat_stats[2] >= 100)
            {
                ((RightAdjustedText)Stats[3]).SetFont("Blue_100", Global.Content);
            }
            ((RightAdjustedText)Stats[3]).text = combat_stats[2].ToString();
            // Sets second units's stats //
            string name2 = is_target_unit ? actor2.name : target.name;

            Name2.draw_offset = new Vector2(28, 4 + (Window.rows + 1) * LINE_HEIGHT);
            Name2.offset      = new Vector2(Font_Data.text_width(name2, Config.UI_FONT) / 2, 0);
            Name2.text        = name2;
            // Icon
            if (weapon2 != null)
            {
                Target_Weapon.text        = weapon2.Name;
                Target_Weapon.draw_offset = new Vector2(
                    32 - Target_Weapon.text_width / 2, 4 + (Window.rows + 2) * LINE_HEIGHT);
                Icon2.index   = weapon2.Image_Index;
                Icon2.texture = Global.Content.Load <Texture2D>(@"Graphics/Icons/" + weapon2.Image_Name);
                if (weapon2.effective_multiplier(target_unit, unit) > 1)
                {
                    Icon2.flash = true;
                }
                effectiveness = weapon2.effective_multiplier(target_unit, unit, false);
                WTA2.set_effectiveness((int)effectiveness, unit.halve_effectiveness());
            }
            else
            {
                Target_Weapon.draw_offset = new Vector2(
                    32 - Font_Data.text_width("---", Config.UI_FONT) / 2, 4 + (Window.rows + 2) * LINE_HEIGHT);
                Target_Weapon.text = "---";
                Icon2.texture      = null;
            }
            // Hp
            //int target_hp = is_target_unit ? actor2.hp : ((Destroyable_Object)target).hp; //Debug

            if (target.hp >= Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
            {
                ((RightAdjustedText)Stats[4]).text = "--";
            }
            else
            {
                ((RightAdjustedText)Stats[4]).text = target.hp.ToString();
            }
            if (is_target_unit && can_counter(unit, target_unit, weapon1, distance))
            {
                // Multiplier
                Mult2.value = Mult2.get_multi(target_unit, unit, weapon2, distance);
                // Dmg
                ((RightAdjustedText)Stats[5]).text = combat_stats[5].ToString();
                // Hit
                if (combat_stats[4] >= 100)
                {
                    ((RightAdjustedText)Stats[6]).SetFont("Blue_100", Global.Content);
                }
                ((RightAdjustedText)Stats[6]).text = combat_stats[4].ToString();
                // Crt
                if (combat_stats[6] >= 100)
                {
                    ((RightAdjustedText)Stats[7]).SetFont("Blue_100", Global.Content);
                }
                ((RightAdjustedText)Stats[7]).text = combat_stats[6].ToString();
            }
            else
            {
                ((RightAdjustedText)Stats[5]).text = "--";
                ((RightAdjustedText)Stats[6]).text = "--";
                ((RightAdjustedText)Stats[7]).text = "--";
            }
            refresh();
        }
        internal override Vector2 target_loc(int target)
        {
            Combat_Map_Object unit1 = Global.game_map.attackable_map_object(target);

            return(unit1.loc_on_map());
        }