Exemple #1
0
        public void FillGridWithCardTypes(List <Ship> ships)
        {
            var names = ships.Select(p => p.Name).Distinct().ToList();

            ClickableToRemove = new List <IClickable>();
            gridCards.RemoveChildren();
            int i = 0;

            foreach (var name in names)
            {
                cardCouple couple = new cardCouple();
                Label      lbl    = new Label(coupleWidth, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.smediumFont, true)
                {
                    Text = name
                };
                Button button = new Button(coupleWidth, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
                {
                    Text = "Select skin"
                };
                button.clickEventObject += setTexture;
                Clickable.Add(button);
                ClickableToRemove.Add(button);
                couple.lbl    = lbl;
                couple.button = button;
                couples.Add(couple);
                gridCards.AddChild(lbl);
                gridCards.AddChild(button);
                i++;
            }

            gridCards.DrawBackground = false;
            gridCards.UpdateP();
            gridCards.UpdateActive(true);
            layout.Update();
        }
Exemple #2
0
        public override void Initialize(ContentManager Content)
        {
            Gui         = new GUI(Content);
            layout      = new RelativeLayout();
            grid        = new Grid();
            buttonsGrid = new Grid();
            cardsGrid   = new Grid(5, 3, CardWidth, CardHeight);
            slots       = new List <CardSlot>();
            for (int row = 0; row < 3; row++)
            {
                for (int column = 0; column < 5; column++)
                {
                    CardSlot c = new CardSlot(CardWidth, CardHeight, Game1.self.GraphicsDevice, Gui);
                    grid.AddChild(c, row, column);
                    c.clickEvent += CardSlotClick;
                    slots.Add(c);
                    Clickable.Add(c);
                }
            }
            grid.Origin = new Point(50, 50);
            grid.UpdateP();
            cardsGrid.WitdhAndHeightColumnDependant = false;
            cardsGrid.Width    = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti);
            cardsGrid.Height   = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * CardGridHeightMulti);
            buttonsGrid.Origin = new Point(Game1.self.graphics.PreferredBackBufferWidth / 2 - 100, Game1.self.graphics.PreferredBackBufferHeight - 200);
            cardsGrid.Origin   = new Point(50, buttonsGrid.Origin.Y - 200);
            Button up = new Button(new Point(cardsGrid.Origin.X + (int)(cardsGrid.Width / 2), cardsGrid.Origin.Y), 60, 30, Game1.self.GraphicsDevice,
                                   Gui, Gui.mediumFont, true)
            {
                Text = "up"
            };

            up.clickEvent += upClick;
            Button down = new Button(new Point(cardsGrid.Origin.X + (int)(cardsGrid.Width / 2), cardsGrid.Origin.Y + 30), 60, 30, Game1.self.GraphicsDevice,
                                     Gui, Gui.mediumFont, true)
            {
                Text = "down"
            };

            down.clickEvent += downClick;

            save = new Button(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                text = "Ready"
            };
            save.clickEvent += onSave;
            tipLabel         = new Label(new Point(grid.Origin.X + grid.Width + 50, grid.Origin.Y), Game1.self.graphics.PreferredBackBufferWidth - 150 - grid.Width, 150, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                Text = "You have 2 minutes to choose your fleet's shape. There's no difference between positions in rows, all the ships in the end will be put to the left border."
            };
            // tipLabel.HeightDerivatingFromText = true;
            // tipLabel.Update();
            layout.AddChild(tipLabel);


            Grid   popupGrid       = new Grid();
            Button popupExitButton = new Button(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                text = "Exit to menu"
            };

            popupExitButton.DrawBackground = false;
            popupExitButton.clickEvent    += onExit;
            Clickable.Add(popupExitButton);
            lbl = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                Text = "You lost the game due to not choosing shape of fleet for longer than 2 minutes"
            };
            lbl.DrawBackground = false;
            popupGrid.AddChild(lbl, 0, 0);
            popupGrid.AddChild(popupExitButton, 1, 0);
            Point popupOrigin = new Point(Game1.self.graphics.PreferredBackBufferWidth / 2 - 100, Game1.self.graphics.PreferredBackBufferHeight / 2 - 150);

            popup      = new Popup(popupOrigin, 200, 300, Game1.self.GraphicsDevice, Gui);
            popup.grid = popupGrid;
            popup.SetToGrid();



            buttonsGrid.AddChild(save, 0, 0);
            Clickable.Add(save);
            layout.AddChild(up);
            layout.AddChild(down);
            Clickable.Add(up);
            Clickable.Add(down);
            cardsGrid.AllVisible             = false;
            cardsGrid.VisibleRows            = 1;
            cardsGrid.ConstantRowsAndColumns = true;
            cardsGrid.MaxChildren            = true;
            cardsGrid.ChildMaxAmount         = 15;
            cardsGrid.UpdateP();
            buttonsGrid.UpdateP();
            SetClickables(true);
            layout.Update();
        }