Exemple #1
0
        private GUI.Frame CreateUnitFrame(Soldier soldier)
        {
            var frame = new GUI.Frame(UIParent);

            frame.SetTexture("images/GUI/unit_background");
            frame.Color  = Color.Black;
            frame.Width  = 164;
            frame.Height = 42;

            var nameText = new GUI.Text(frame);

            nameText.SetFont("fonts/UnitName");
            nameText.Value    = soldier.Name + " " /* + soldier.GetHashCode()*/;
            nameText.X        = 4;
            nameText.Y        = 1;
            frame["nameText"] = nameText;

            var healthBarBg = new GUI.Frame(frame);

            healthBarBg.SetTexture("images/GUI/health_background");
            healthBarBg.Width    = 136;
            healthBarBg.Height   = 13;
            healthBarBg.X        = 3;
            healthBarBg.Y        = 19;
            frame["healthBarBg"] = healthBarBg;

            var healthBar = new GUI.Frame(healthBarBg);

            healthBar.SetTexture("images/GUI/bar_solid");
            healthBar.Color    = Color.Red;
            healthBar.Width    = (int)((healthBarBg.Width - 2) * (soldier.GetComponent <Component.Stat>().HP / soldier.GetComponent <Component.Stat>().MaxHP));
            healthBar.Height   = 11;
            healthBar.X        = 1;
            healthBar.Y        = 1;
            frame["healthBar"] = healthBar;

            var actionBarBg = new GUI.Frame(frame);

            actionBarBg.SetTexture("images/GUI/health_background");
            actionBarBg.Width    = 136;
            actionBarBg.Height   = 8;
            actionBarBg.X        = 3;
            actionBarBg.Y        = 31;
            frame["actionBarBg"] = actionBarBg;

            var actionBar = new GUI.Frame(actionBarBg);

            actionBar.SetTexture("images/GUI/bar_solid");
            actionBar.Color    = Color.Orange;
            actionBar.Width    = (int)((healthBarBg.Width - 2) * (soldier.GetComponent <Component.Stat>().HP / soldier.GetComponent <Component.Stat>().MaxHP));
            actionBar.Height   = 6;
            actionBar.X        = 1;
            actionBar.Y        = 1;
            frame["actionBar"] = actionBar;

            for (int i = 1; i < 10; i++)
            {
                var line = new GUI.Frame(actionBar);
                line.Texture = Utility.GetSolidTexture();
                line.Color   = Color.Black;
                line.Height  = 6;
                line.Width   = 1;
                line.X       = (int)(i * ((float)actionBarBg.Width / 10f)) - 1;
            }

            return(frame);
        }
Exemple #2
0
        private GUI.Frame CreateUnitFrame(Soldier soldier)
        {
            var frame = new GUI.Frame(UIParent);
            frame.SetTexture("images/GUI/unit_background");
            frame.Color = Color.Black;
            frame.Width = 164;
            frame.Height = 42;

            var nameText = new GUI.Text(frame);
            nameText.SetFont("fonts/UnitName");
            nameText.Value = soldier.Name + " "/* + soldier.GetHashCode()*/;
            nameText.X = 4;
            nameText.Y = 1;
            frame["nameText"] = nameText;

            var healthBarBg = new GUI.Frame(frame);
            healthBarBg.SetTexture("images/GUI/health_background");
            healthBarBg.Width = 136;
            healthBarBg.Height = 13;
            healthBarBg.X = 3;
            healthBarBg.Y = 19;
            frame["healthBarBg"] = healthBarBg;

            var healthBar = new GUI.Frame(healthBarBg);
            healthBar.SetTexture("images/GUI/bar_solid");
            healthBar.Color = Color.Red;
            healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent<Component.Stat>().HP / soldier.GetComponent<Component.Stat>().MaxHP));
            healthBar.Height = 11;
            healthBar.X = 1;
            healthBar.Y = 1;
            frame["healthBar"] = healthBar;

            var actionBarBg = new GUI.Frame(frame);
            actionBarBg.SetTexture("images/GUI/health_background");
            actionBarBg.Width = 136;
            actionBarBg.Height = 8;
            actionBarBg.X = 3;
            actionBarBg.Y = 31;
            frame["actionBarBg"] = actionBarBg;

            var actionBar = new GUI.Frame(actionBarBg);
            actionBar.SetTexture("images/GUI/bar_solid");
            actionBar.Color = Color.Orange;
            actionBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent<Component.Stat>().HP / soldier.GetComponent<Component.Stat>().MaxHP));
            actionBar.Height = 6;
            actionBar.X = 1;
            actionBar.Y = 1;
            frame["actionBar"] = actionBar;

            for (int i = 1; i < 10; i++)
            {
                var line = new GUI.Frame(actionBar);
                line.Texture = Utility.GetSolidTexture();
                line.Color = Color.Black;
                line.Height = 6;
                line.Width = 1;
                line.X = (int)(i * ((float)actionBarBg.Width/10f)) - 1;
            }

            return frame;
        }