Example #1
0
        public StandardForm CreateHealthShieldBars()
        {
            var sf = new StandardForm(InternalWindows, _spriteBatch, _content, "");

            sf.SetFont(_textureManager.HUD_Font);
            sf.SetTitleColor(Color.Transparent);
            sf.IsTextVisible = false;
            sf.SetBackgroundMaterial(@"GUI\Windows\3Bars");
            sf.Size     = new WindowSize(sf.BackgroundMaterial.Width, sf.BackgroundMaterial.Height);
            sf.IsStatic = false;
            sf.Centered = true;
            sf.Location = new Vector2(0, 0);

            //Static Button

            Button staticButton = CreateStaticButton("staticButton", sf);

            staticButton.Location = sf.Location;
            staticButton.Trigger  = true;
            staticButton.Size     = new WindowSize(staticButton.BackgroundMaterial.Width,
                                                   staticButton.BackgroundMaterial.Height);

            //Health Bar
            Bar b2 = CreateBar("", sf);

            b2.SetBackgroundMaterial(@"GUI\Windows\Bar_Health");
            b2.OnUpdateEvent += HealthBarUpdate;
            b2.Size           = new WindowSize(b2.BackgroundMaterial.Width, b2.BackgroundMaterial.Height);
            b2.Location       = new Vector2(0, 0);
            b2.IsStatic       = true;

            Label lbl = CreateLabel(ref sf, "Health");

            lbl.SetFont(_textureManager.HUD_Font);
            lbl.SetTextColor(Color.AntiqueWhite);
            lbl.OnUpdateEvent += HealthLabelUpdate;
            lbl.IsStatic       = true;
            lbl.Text           = "" + _shipManager.PlayerShip.CurrentHealth;
            //lbl.TextColor = Color.AntiqueWhite;
            lbl.Location =
                new Vector2(
                    (int)b2.Location.X + (b2.BackgroundMaterial.Width / 2f) -
                    (_debugTextManager.GetFont().MeasureString(b2.Text).X / 2f),
                    b2.Location.Y + (b2.BackgroundMaterial.Height / 4f));


            //Shields Bar
            Bar b = CreateBar("", sf);

            b.SetBackgroundMaterial(@"GUI\Windows\Bar_Shields");
            b.OnUpdateEvent += ShieldsBarUpdate;
            b.Size           = new WindowSize(b.BackgroundMaterial.Width, b.BackgroundMaterial.Height);
            b.IsStatic       = true;
            b.Location       = new Vector2(0, 33);

            Label lbl2 = CreateLabel(ref sf, "Shields");

            lbl2.SetFont(_textureManager.HUD_Font);
            lbl2.SetTextColor(Color.AntiqueWhite);
            lbl2.OnUpdateEvent += ShieldsLabelUpdate;
            lbl2.IsStatic       = true;
            lbl2.Text           = "" + _shipManager.PlayerShip.CurrentShields;
            //lbl2.TextColor = Color.LightBlue;
            lbl2.Location =
                new Vector2(
                    (int)b.Location.X + (b.BackgroundMaterial.Width / 2f) -
                    (_debugTextManager.GetFont().MeasureString(b.Text).X / 2f),
                    b.Location.Y + (b.BackgroundMaterial.Height / 4f));


            //Energy Bar
            Bar b3 = CreateBar("", sf);

            b3.SetBackgroundMaterial(@"GUI\Windows\Bar_Energy");
            b3.OnUpdateEvent += EnergyBarUpdate;
            b3.Size           = new WindowSize(b3.BackgroundMaterial.Width, b3.BackgroundMaterial.Height);
            b3.IsStatic       = true;
            b3.Location       = new Vector2(0, 66);

            Label lbl3 = CreateLabel(ref sf, "Energy");

            lbl3.SetFont(_textureManager.HUD_Font);
            lbl3.SetTextColor(Color.AntiqueWhite);
            lbl3.OnUpdateEvent += EnergyLabelUpdate;
            lbl3.IsStatic       = true;
            lbl3.Text           = "" + _shipManager.PlayerShip.CurrentShields;
            //lbl3.TextColor = Color.LightBlue;
            lbl3.Location =
                new Vector2(
                    (int)b3.Location.X + (b3.BackgroundMaterial.Width / 2f) -
                    (_debugTextManager.GetFont().MeasureString(b3.Text).X / 2f),
                    b3.Location.Y + (b3.BackgroundMaterial.Height / 4f));


            sf.Show();

            return(sf);
        }