internal StatusSkillIconUINode(
            string helpLabel,
            Func <Game_Unit, SkillState> skillFormula)
            : base(helpLabel)
        {
            SkillFormula = skillFormula;

            SkillIcon             = new Icon_Sprite();
            SkillIcon.size        = new Vector2(Config.SKILL_ICON_SIZE, Config.SKILL_ICON_SIZE);
            SkillIcon.draw_offset = new Vector2(0, 0);

            Gauge             = new Mastery_Gauge(0);
            Gauge.draw_offset = new Vector2(0, 0);

            Size = new Vector2(96, Config.SKILL_ICON_SIZE);
        }
Example #2
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();
        }