Ejemplo n.º 1
0
        internal StatusPrimaryStatUINode(
            string helpLabel,
            string label,
            Func <Game_Unit, PrimaryStatState> statFormula,
            Func <Game_Unit, Color> labelHueFormula,
            int textOffset = 48)
            : base(helpLabel, label, null, textOffset)
        {
            StatFormula     = statFormula;
            LabelHueFormula = labelHueFormula;

            if (LabelHueFormula != null)
            {
                Label.SetColor(Global.Content, "StatHueWhite");
            }

            Bonus             = new TextSprite();
            Bonus.draw_offset = new Vector2(textOffset + 0, 0);
            Bonus.SetFont(Config.UI_FONT + "Bonus", Config.UI_FONT);

            Bar             = new Stat_Bar();
            Bar.draw_offset = new Vector2(16, 8);
            Bar.offset      = new Vector2(-2, 0);

            PenaltyArrow             = new Weapon_Triangle_Arrow();
            PenaltyArrow.draw_offset = new Vector2(16, 0) + new Vector2(-12, 1);

            Size = new Vector2(textOffset + 24, 16);
        }
        protected override void draw_images(Game_Unit unit)
        {
            Window_Img.team = unit.team;
            var  selected_unit   = Global.game_map.get_selected_unit();
            var  player_unit     = selected_unit;
            bool player_selected = true;

            // Swap units if the selected unit is on an enemy team
            if (player_unit != null &&
                !player_unit.is_player_allied)
            {
                Game_Unit temp = unit;
                unit            = player_unit;
                player_unit     = temp;
                player_selected = false;
            }

            Item.flash       = false;
            TargetItem.flash = false;

            // Name
            set_name(unit);
            Name.offset = new Vector2(Name.text_width / 2, 0); //Debug

            Weapon_Triangle_Arrow.ResetWeaponTriangle(WTA1, WTA2);

            Item.texture = null;
            var unitWeapon = unit.actor.weapon;

            if (!player_selected && unit.is_on_siege())
            {
                unitWeapon = unit.items[Siege_Engine.SiegeInventoryIndex].to_weapon;
            }
            if (unitWeapon != null)
            {
                string filename = string.Format(@"Graphics/Icons/{0}", unitWeapon.Image_Name);
                if (Global.content_exists(filename))
                {
                    Item.texture = Global.Content.Load <Texture2D>(filename);
                }
                Item.index = unitWeapon.Image_Index;
            }

            var playerUnitWeapon = player_unit.actor.weapon;

            if (player_selected && player_unit.is_on_siege())
            {
                playerUnitWeapon = player_unit.items[Siege_Engine.SiegeInventoryIndex].to_weapon;
            }

            var selectedUnitWeapon = player_selected ? playerUnitWeapon : unitWeapon;

            // HP
            if (player_unit == null || player_unit == unit ||
                selectedUnitWeapon == null || selectedUnitWeapon.is_staff())
            {
                Window_Width = 56;
                Window_Img.set_width(Window_Width);
                target_info_visible(false);

                Hp_Gauge.set_val(unit.actor.hp, unit.actor.maxhp);
            }
            else
            {
                Window_Width = 56 + 72;
                Window_Img.set_width(Window_Width);
                target_info_visible(true);

                TargetName.text   = player_unit.actor.name;
                TargetName.offset = new Vector2(TargetName.text_width / 2, 0); //Debug
                //TargetName.offset = new Vector2(24, 0);

                TargetItem.texture = null;
                if (playerUnitWeapon != null)
                {
                    string filename = string.Format(@"Graphics/Icons/{0}", playerUnitWeapon.Image_Name);
                    if (Global.content_exists(filename))
                    {
                        TargetItem.texture = Global.Content.Load <Texture2D>(filename);
                    }
                    TargetItem.index = playerUnitWeapon.Image_Index;
                }

                // Player unit has no weapon
                if (playerUnitWeapon == null || playerUnitWeapon.is_staff())
                {
                    (Hp_Gauge as Unit_Info_Hp_Gauge_Damage).set_val(
                        unit.actor.hp, unit.actor.maxhp);
                }
                else
                {
                    int distance = playerUnitWeapon != null ?
                                   playerUnitWeapon.Min_Range : 1;
                    var stats = new CombatStats(player_unit.id, unit.id,
                                                itemIndex: player_selected && player_unit.is_on_siege() ?
                                                Siege_Engine.SiegeInventoryIndex : -1,
                                                distance: distance)
                    {
                        location_bonuses = CombatLocationBonuses.NoAttackerBonus
                    };
                    (Hp_Gauge as Unit_Info_Hp_Gauge_Damage).set_val(
                        unit.actor.hp, unit.actor.maxhp,
                        stats.inverse_rounds_to_kill());

                    Weapon_Triangle_Arrow.SetWeaponTriangle(
                        WTA2,
                        player_unit,
                        unit,
                        playerUnitWeapon,
                        unitWeapon,
                        distance);
                    if (playerUnitWeapon.effective_multiplier(player_unit, unit) > 1)
                    {
                        TargetItem.flash = true;
                    }
                }

                // Target has no weapon
                if (unitWeapon == null || unitWeapon.is_staff())
                {
                    TargetHpGauge.set_val(unit.actor.hp, unit.actor.maxhp);
                }
                else
                {
                    int distance = unitWeapon != null ?
                                   unitWeapon.Min_Range : 1;
                    var target_stats = new CombatStats(unit.id, player_unit.id,
                                                       itemIndex: !player_selected && unit.is_on_siege() ?
                                                       Siege_Engine.SiegeInventoryIndex : -1,
                                                       distance: distance)
                    {
                        location_bonuses = CombatLocationBonuses.NoDefenderBonus
                    };
                    TargetHpGauge.set_val(
                        player_unit.actor.hp, player_unit.actor.maxhp,
                        target_stats.inverse_rounds_to_kill());

                    Weapon_Triangle_Arrow.SetWeaponTriangle(
                        WTA1,
                        unit,
                        player_unit,
                        unitWeapon,
                        playerUnitWeapon,
                        distance);
                    if (unitWeapon.effective_multiplier(unit, player_unit) > 1)
                    {
                        Item.flash = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void InitializeImages()
        {
            Window_Img       = new SystemWindowHeadered();
            Window_Img.width = this.Width;
            Window_Img.set_lines(4);
            Window_Img.stereoscopic = Config.RANKING_WINDOW_DEPTH;
            Text = new List <TextSprite>();
            // Chapter name and difficulty
            var name = new TextSprite(
                Config.UI_FONT, Global.Content, "Yellow",
                new Vector2(12, 8),
                Global.data_chapters[Ranking.ChapterId].ShortName);

            name.stereoscopic = Config.RANKING_WINDOW_DEPTH;
            Text.Add(name);
            var difficulty = new RightAdjustedText(
                Config.UI_FONT, Global.Content, "Blue",
                new Vector2(Window_Img.width - 12, 8),
                Ranking.Difficulty.ToString());

            difficulty.stereoscopic = Config.RANKING_WINDOW_DEPTH;
            Text.Add(difficulty);

            for (int i = 0; i < 4; i++)
            {
                var label = new TextSprite();
                label.loc = new Vector2(8, 24 + i * 16);
                label.SetFont(Config.UI_FONT, Global.Content, "Yellow");
                label.stereoscopic = Config.RANKING_WINDOW_DEPTH;
                Text.Add(label);
            }
            Text[Text.Count - 4].text = "Turns";
            Text[Text.Count - 3].text = "Combat";
            Text[Text.Count - 2].text = "Experience";
            Text[Text.Count - 1].text = "Total";
            //Text[3].text = "MVP";
            for (int i = 0; i < 4; i++)
            {
                var value = new RightAdjustedText();
                value.loc = new Vector2(Window_Img.width - 8, 24 + i * 16);
                value.SetFont(Config.UI_FONT, Global.Content, "Blue");
                value.stereoscopic = Config.RANKING_WINDOW_DEPTH;
                Text.Add(value);
            }
            Text[Text.Count - 4].text = Ranking.turns.ToString();
            Text[Text.Count - 3].text = Ranking.combat.ToString();
            Text[Text.Count - 2].text = Ranking.exp.ToString();
            Text[Text.Count - 1].text = Ranking.score.ToString();

            Arrows = new List <Weapon_Triangle_Arrow>();
            if (PreviousRanking == null)
            {
                Window_Img.tint = new Color(192, 192, 192, 255);
            }
            else
            {
                for (int i = 4; i >= 1; i--)
                {
                    var text = Text[Text.Count - i];
                    text.loc.X -= 4;

                    var arrow = new Weapon_Triangle_Arrow();
                    arrow.loc          = text.loc + new Vector2(-12, 0);
                    arrow.stereoscopic = Config.RANKING_WINDOW_DEPTH;
                    Arrows.Add(arrow);
                }
                CompareRanking(0, Ranking.turns, PreviousRanking.turns);
                CompareRanking(1, Ranking.combat, PreviousRanking.combat);
                CompareRanking(2, Ranking.exp, PreviousRanking.exp);
                CompareRanking(3, Ranking.score, PreviousRanking.score);
            }
        }