Пример #1
0
        public virtual void set_images(Game_Unit unit)
        {
            Hp1.text  = "--";
            Dmg1.text = "--";
            Hit1.text = "--";
            Crt1.text = "--";

            var stats = new BattlerStats(unit.id);

            Hp1.text   = unit.hp.ToString();
            ASpd1.text = unit.atk_spd().ToString();

            if (stats.has_non_staff_weapon)
            {
                Dmg1.text = stats.dmg().ToString();
                Hit1.text = stats.hit().ToString();
                Crt1.text = stats.crt().ToString();
            }

            Hp2.text   = "--";
            Dmg2.text  = "--";
            Hit2.text  = "--";
            Crt2.text  = "--";
            ASpd2.text = "--";

            var player_unit = Global.game_map.get_selected_unit();

            if (player_unit != null)
            {
                Hp2.text   = player_unit.hp.ToString();
                ASpd2.text = player_unit.atk_spd().ToString();

                if (player_unit.actor.weapon != null)
                {
                    if (!player_unit.actor.weapon.is_staff())
                    {
                        var combat = Combat.combat_stats(player_unit.id, unit.id, player_unit.min_range());

                        stats = new BattlerStats(player_unit.id);

                        Dmg2.text = combat[1].ToString();
                        Hit2.text = combat[0].ToString();
                        Crt2.text = combat[2].ToString();

                        Dmg1.text = "--";
                        Hit1.text = "--";
                        Crt1.text = "--";
                        if (combat[4] != null)
                        {
                            Dmg1.text = combat[5].ToString();
                            Hit1.text = combat[4].ToString();
                            Crt1.text = combat[6].ToString();
                        }
                    }
                }
            }
        }
Пример #2
0
        protected void initialize_sprites()
        {
            // Black Screen
            Black_Screen           = new Sprite();
            Black_Screen.texture   = Global.Content.Load <Texture2D>(@"Graphics/White_Square");
            Black_Screen.dest_rect = new Rectangle(0, 0, Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT);
            Black_Screen.tint      = new Color(0, 0, 0, 255);
            // Background
            Background              = new Menu_Background();
            Background.texture      = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Status_Background");
            Background.vel          = new Vector2(-0.25f, 0);
            Background.tile         = new Vector2(3, 2);
            Background.stereoscopic = Config.MAPMENU_BG_DEPTH;

            // UI Nodes
            TopPanelNodes = new List <StatusUINode>();
            // Top Panel //
            // Top Panel
            Top_Panel = new Status_Top_Panel_Bg(new List <Texture2D> {
                Global.Content.Load <Texture2D>(@"Graphics/Pictures/Portrait_bg"),
                Global.Content.Load <Texture2D>(@"Graphics/Windowskins/WindowPanel")
            });
            Top_Panel.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Face Bg
            Face_Bg              = new Menu_Background();// Sprite(); //Debug
            Face_Bg.texture      = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Portrait_bg");
            Face_Bg.loc          = new Vector2(4, 4);
            Face_Bg.src_rect     = new Rectangle(12, 4, 8, 8);
            Face_Bg.tile         = new Vector2(11, 9);
            Face_Bg.stereoscopic = Config.STATUS_FACE_BG_DEPTH;
            // Map Sprite
            Map_Sprite              = new Character_Sprite();
            Map_Sprite.draw_offset  = MAP_SPRITE_LOC + new Vector2(16, 16);
            Map_Sprite.facing_count = 3;
            Map_Sprite.frame_count  = 3;
            Map_Sprite.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Map Sprite Platform
            Platform              = new Sprite();
            Platform.texture      = Global.Content.Load <Texture2D>(@"Graphics/Characters/StatusPlatform");
            Platform.loc          = MAP_SPRITE_LOC;
            Platform.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Name
            TopPanelNodes.Add(new StatusTextUINode(
                                  "Name",
                                  (Game_Unit unit) => unit.name, true));
            TopPanelNodes.Last().loc          = new Vector2(112, 4);
            TopPanelNodes.Last().draw_offset  = new Vector2(34, 0);
            TopPanelNodes.Last().Size         = new Vector2(68, 16);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;

            // Class Name
            TopPanelNodes.Add(new StatusTextUINode(
                                  "Class",
                                  (Game_Unit unit) => unit.actor.class_name));
            TopPanelNodes.Last().loc          = new Vector2(104, 24);
            TopPanelNodes.Last().Size         = new Vector2(72, 16);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;

            // Lives
            TopPanelNodes.Add(new StatusLivesUINode("Lives"));
            TopPanelNodes.Last().loc          = new Vector2(180, 60);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // LV/HP/etc

            TopPanelNodes.Add(new StatusStatLargeLabelUINode(
                                  "Lvl", "LV", (Game_Unit unit) => unit.actor.level.ToString(), 32));
            TopPanelNodes.Last().loc          = new Vector2(104, 40);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            Func <Game_Unit, DirectionFlags, bool> lvl_cheat = (unit, dir) =>
            {
                int lvl_gain = 0;
                if (dir.HasFlag(DirectionFlags.Right))
                {
                    lvl_gain = 1;
                }
                else if (dir.HasFlag(DirectionFlags.Left))
                {
                    lvl_gain = -1;
                }
                unit.actor.level += lvl_gain;
                unit.queue_move_range_update();
                return(lvl_gain != 0);
            };

#if DEBUG
            TopPanelNodes.Last().set_cheat(lvl_cheat);
#endif

            TopPanelNodes.Add(new StatusStatUINode(
                                  "Exp", "$", (Game_Unit unit) =>
                                  unit.actor.can_level() ? unit.actor.exp.ToString() : "--", 24));
            TopPanelNodes.Last().loc          = new Vector2(136, 40);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            Func <Game_Unit, DirectionFlags, bool> exp_cheat = (unit, dir) =>
            {
                int exp_gain = 0;
                if (dir.HasFlag(DirectionFlags.Right))
                {
                    exp_gain = 1;
                }
                else if (dir.HasFlag(DirectionFlags.Left))
                {
                    exp_gain = -1;
                }
                unit.actor.exp = (int)MathHelper.Clamp(
                    unit.actor.exp + exp_gain,
                    0, Global.ActorConfig.ExpToLvl - 1);
                return(exp_gain != 0);
            };
#if DEBUG
            TopPanelNodes.Last().set_cheat(exp_cheat);
#endif

            Func <Game_Unit, Color> label_color = null;
            if (show_stat_colors(Stat_Labels.Hp))
            {
                label_color = (Game_Unit unit) =>
                {
                    if (unit.average_stat_hue_shown)
                    {
                        return(unit.actor.stat_color(Stat_Labels.Hp));
                    }

                    return(Color.White);
                };
            }
            TopPanelNodes.Add(new StatusHpUINode(
                                  "Hp",
                                  "HP",
                                  (Game_Unit unit) =>
            {
                if (unit.actor.hp >=
                    Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
                {
                    return("--");
                }
                else
                {
                    return(unit.actor.hp.ToString());
                }
            },
                                  (Game_Unit unit) =>
            {
                if (unit.actor.maxhp >=
                    Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
                {
                    return("--");
                }
                else
                {
                    return(unit.actor.maxhp.ToString());
                }
            },
                                  label_color));
            TopPanelNodes.Last().loc          = new Vector2(104, 56);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
#if DEBUG
            TopPanelNodes.Last().set_cheat(
                Status_Page_1.stat_cheat(Stat_Labels.Hp));
#endif

            // Battle Stat Labels
            Battle_Stat_Labels = new List <TextSprite>();
            for (int i = 0; i < 1; i++)
            {
                Battle_Stat_Labels.Add(new TextSprite());
                Battle_Stat_Labels[i].loc = new Vector2(204 + (i / 4) * 56, 8 + (i % 4) * 16);
                Battle_Stat_Labels[i].SetFont(Config.UI_FONT, Global.Content, "Yellow");
                Battle_Stat_Labels[i].text         = "doop";
                Battle_Stat_Labels[i].stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            }
            Battle_Stat_Labels[0].SetColor(Global.Content, "White");
            Battle_Stat_Labels[0].text = "Battle Stats";
            // Battle Stats
            for (int i = 1; i < 8; i++)
            {
                string help_label;
                string label;
                Func <Game_Unit, string> stat_formula;
                switch (i)
                {
                // Atk
                case 1:
                default:
                    help_label   = "Atk";
                    label        = "Atk";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon)
                        {
                            return("--");
                        }
                        return(stats.dmg().ToString());
                    };
                    break;

                // Hit
                case 2:
                    help_label   = "Hit";
                    label        = "Hit";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon)
                        {
                            return("--");
                        }
                        return(stats.hit().ToString());
                    };
                    break;

                // Dodge
                case 7:
                    help_label   = "Dodge";
                    label        = "Dodge";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        return(stats.dodge().ToString());
                    };
                    break;

                // Range
                case 4:
                    help_label   = "Range";
                    label        = "Rng";
                    stat_formula = (Game_Unit unit) =>
                    {
                        if (unit.actor.weapon == null ||
                            unit.actor.weapon.is_staff())
                        {
                            return("--");
                        }

                        Data_Weapon weapon    = unit.actor.weapon;
                        int         min_range = unit.min_range();
                        int         max_range = unit.max_range();
                        if (min_range == max_range)
                        {
                            return(min_range.ToString());
                        }
                        else
                        {
                            return(string.Format("{0}-{1}", min_range, max_range));
                        }
                    };
                    break;

                // Crit
                case 3:
                    help_label   = "Crit";
                    label        = "Crit";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon || !stats.can_crit())
                        {
                            return("--");
                        }
                        return(stats.crt().ToString());
                    };
                    break;

                // Avoid
                case 6:
                    help_label   = "Avoid";
                    label        = "Avoid";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        return(stats.avo().ToString());
                    };
                    break;

                // AS
                case 5:
                    help_label   = "AS";
                    label        = "AS";
                    stat_formula = (Game_Unit unit) => unit.atk_spd().ToString();
                    break;
                }

                Vector2 loc = new Vector2(204 + (i / 4) * 56, 8 + (i % 4) * 16);

                TopPanelNodes.Add(new StatusStatUINode(help_label, label, stat_formula));
                TopPanelNodes.Last().loc          = loc;
                TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            }
            // Rescue Icon
            Rescue_Icon              = new Sprite();
            Rescue_Icon.texture      = Global.Content.Load <Texture2D>(@"Graphics/Characters/RescueIcon");
            Rescue_Icon.loc          = new Vector2(103, -5);
            Rescue_Icon.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Pages //
            Pages.Add(new Status_Page_1());
            Pages.Add(new Status_Page_2());
            Pages.Add(new Status_Page_3());
            // Page Arrows
            Left_Page_Arrow                = new Page_Arrow();
            Left_Page_Arrow.loc            = new Vector2(4, 84);
            Left_Page_Arrow.stereoscopic   = Config.STATUS_ARROW_DEPTH;
            Left_Page_Arrow.ArrowClicked  += Left_Page_Arrow_ArrowClicked;
            Right_Page_Arrow               = new Page_Arrow();
            Right_Page_Arrow.loc           = new Vector2(Config.WINDOW_WIDTH - 4, 84);
            Right_Page_Arrow.mirrored      = true;
            Right_Page_Arrow.stereoscopic  = Config.STATUS_ARROW_DEPTH;
            Right_Page_Arrow.ArrowClicked += Right_Page_Arrow_ArrowClicked;

            create_cancel_button();

            set_images();
        }