示例#1
0
        // Constructor: Initialise the individual elements
        public Entity_UIPanel_StarSystem(float x, float y, string name, string systemtype)
        {
            X = x;
            Y = y;

            Label      = name;
            SystemType = systemtype;

            // Panel image
            Image_Background = new Entity_Image(X, Y, "", false);
            {
                Image_Background.NineSlice(Program.PATH_PA + "media/ui/main/shared/img/panel/img_menu_panel.png", 24, 24, Width, Height);

                Image_Background.image.Scroll = 0;
                //Image_Background.SetTarget( center );

                Image_Background.Layer = Helper.Layer_UI;
            }
            // System name
            Text_Label = new Text(Label, Program.Font, 20);
            {
                Text_Label.CenterOrigin();
                Text_Label.SetPosition(new Vector2(0, -80));
                Text_Label.Scroll = 0;
                //Text_Label.Color = Color.Green;
            }
            Image_Background.AddGraphic(Text_Label);
            // System type (i.e. map)
            Text_SystemType = new Text("(SystemType)", Program.Font, 16);
            {
                Text_SystemType.CenterOrigin();
                Text_SystemType.SetPosition(new Vector2(0, -62));
                Text_SystemType.Scroll = 0;
                Text_SystemType.Color  = Color.Gray;
            }
            Image_Background.AddGraphic(Text_SystemType);
            // System information (i.e. number of planets)
            Text_SystemInfo = new Text("(Planets: N/A)", Program.Font, 12);
            {
                Text_SystemInfo.CenterOrigin();
                Text_SystemInfo.SetPosition(new Vector2(0, -48));
                Text_SystemInfo.Scroll = 0;
                Text_SystemInfo.Color  = Color.Shade(0.7f);
            }
            Image_Background.AddGraphic(Text_SystemInfo);
            // Button Action
            Button_Action = new Entity_UI_Button();
            {
                Vector2 pos = new Vector2(X - Game.Instance.HalfWidth, Y - Game.Instance.HalfHeight + 72);
                Button_Action.Offset.Y     = -1;
                Button_Action.ButtonBounds = new Vector4(pos.X, pos.Y, 128, 48);
                Button_Action.Scroll       = new Vector2(0, 0);

                Button_Action.Layer = Helper.Layer_UI;
            }
            UpdateButton();

            // Add ui press collider
            AddCollider <BoxCollider>(new BoxCollider(Width, Height));
            Collider.CenterOrigin();
            Collider.SetPosition(-Game.Instance.HalfWidth, -Game.Instance.HalfHeight);

            Layer = Helper.Layer_UI;
        }
        // Added To Scene: Initialise individual elements
        public override void Added()
        {
            base.Added();

            // Panel image
            Image_Background = new Entity_Image(X, Y, "", false);
            {
                Image_Background.NineSlice(Program.PATH_PA + "media/ui/main/shared/img/panel/img_menu_panel.png", 24, 24, 256, 364);

                //Image_Background.SetTarget( center );

                Image_Background.Layer = Helper.Layer_UI;
            }
            Scene.Instance.Add(Image_Background);

            // Icon image
            Image_Icon = new Entity_Image(X, Y - 96, IconFile);
            {
                //Image_Icon.SetTarget( center );
            }
            Scene.Instance.Add(Image_Icon);

            // Card name
            Text_Label = new Text(Label, Program.Font, 20);
            {
                Text_Label.CenterOrigin();
                Text_Label.SetPosition(new Vector2(0, 64));
                Text_Label.Color = Color.Green;
            }
            Image_Icon.AddGraphic(Text_Label);

            // Description
            Text_Description = new RichText(Description, Program.Font, 12);
            {
                Text_Description.SetPosition(new Vector2(-128 + 16, 96));
                Text_Description.TextWidth = 256 - 32;
                Text_Description.WordWrap  = true;
            }
            Image_Icon.AddGraphic(Text_Description);

            // Panel image
            Image_Button_Background = new Entity_Image(X, Y + 140, "", false);
            {
                Image_Button_Background.NineSlice(Program.PATH_PA + "media/ui/main/shared/img/panel/img_panel_std_black.png", 120, 86, 326, 156);

                //Image_Button_Background.SetTarget( center );
            }
            Scene.Instance.Add(Image_Button_Background);

            // Button Choose
            Button_Choose = new Entity_UI_Button();
            {
                Button_Choose.Label = "DOWNLOAD";
                Vector2 pos = new Vector2(X, Y + 134);
                Button_Choose.Center       = Vector2.Zero;
                Button_Choose.Offset.Y     = -1;
                Button_Choose.ButtonBounds = new Vector4(pos.X, pos.Y, 196, 48);
                Button_Choose.Scroll       = new Vector2(1, 1);
                Button_Choose.OnPressed    = delegate(Entity_UI_Button self)
                {
                    self.Image.image.Color = self.Colour_Hover * Color.Gray;
                    AudioManager.Instance.PlaySound("resources/audio/ui_click.wav");
                };
                Button_Choose.OnReleased = delegate(Entity_UI_Button self)
                {
                    NetworkManager.SendPickCard(Label);
                    Helper.GetGameScene().HideCards();
                    AudioManager.Instance.PlaySound("resources/audio/ui_click.wav");
                };

                Button_Choose.Layer = Helper.Layer_UI;
            }
            Scene.Instance.Add(Button_Choose);

            Layer = Helper.Layer_UI;
        }