public void ReDo() { ClickableToRemove = new List <IClickable>(); Clickable.ForEach(p => { if (p is Card || p is CardSlot) { ClickableToRemove.Add(p); } }); ClickableToRemove.ForEach(p => Clickable.Remove(p)); grid.RemoveChildren(); 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); } } var autoEvent = new AutoResetEvent(false); time = 0; timer = new Timer(timerStart, autoEvent, 0, 1000); grid.UpdateP(); }
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(); }
private void FillTopShips(List <Ship> ships) { foreach (var ship in ships) { Card dc = new Card(cardWidth, cardHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, ship); Clickable.Add(dc); dc.clickEvent += CardClick; ShipsInTop.Add(dc); } }
public override void Initialize(ContentManager Content) { ClickableToRemove = new List <IClickable>(); Gui = new GUI(Content); gridCards = new Grid(2, 100, coupleWidth, coupleHeight); gridCards.DrawBorder = true; gridCards.BorderSize = 3; gridCards.WitdhAndHeightColumnDependant = false; gridCards.AllVisible = false; gridCards.VisibleRows = 5; gridCards.ConstantRowsAndColumns = true; gridCards.MaxChildren = true; gridCards.ChildMaxAmount = 200; gridCards.Height = 5 * coupleHeight + 6 * gridCards.rowOffset; gridCards.Width = 2 * coupleWidth + gridCards.columnOffset; up = new Button(gridCards.Width, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "up" }; down = new Button(gridCards.Width, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "down" }; back = new Button(gridCards.Width, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Back to menu" }; up.clickEvent += UpClick; down.clickEvent += DownClick; back.clickEvent += OnExit; Clickable.Add(back); layout.AddChild(gridCards); layout.AddChild(down); layout.AddChild(up); layout.AddChild(back); Clickable.Add(up); Clickable.Add(down); back.Update(); up.Update(); down.Update(); gridCards.UpdateP(); int z = 243123; SetClickables(true); layout.Update(); }
private void OnAdd() { if (DeckInputBox.Text.Length > 0 && gridRight.CanHaveMoreChildren()) { Deck newDeck = new Deck(new Point(), 20, (int)(gridRight.Height * 0.1), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false, DeckInputBox.Text); Decks.Add(newDeck); newDeck.RecentlyAdded = true; newDeck.clickEvent += DeckClick; gridRight.AddChild(newDeck); DeckInputBox.Text = ""; Clickable.Add(newDeck); gridRight.ResizeChildren(); } }
public void LoadDecksAndShips(List <Fleet> fleets, List <Ship> ships) { Decks.ForEach(p => Clickable.Remove(p)); Decks.Clear(); fleets.ForEach(p => { Deck z = FleetToDeck(p); z.clickEvent += DeckClick; Clickable.Add(z); Decks.Add(z); RefreshRightGrid(); }); this.ships = ships; Decks.ForEach(p => p.RecentlyAdded = false); }
private void FillBotShips() { var ships = Game1.self.OwnedShips; if (ships != null) { foreach (var ship in ships) { Card dc = new Card(cardWidth, cardHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, ship); Clickable.Add(dc); dc.clickEvent += CardClick; ShipsInBot.Add(dc); ClickableToRemove.Add(dc); } } }
public void Reinitialize(List <LootBox> loots) { int column = 0; loots.ForEach(p => { LootBoxElement lb = new LootBoxElement(200, 200, Game1.self.GraphicsDevice, Gui, GetRarity(p), p); BoxesGrid.AddChild(lb, 0, column); lb.clickEvent += GetLootbox; lb.ActiveChangeable = true; Clickable.Add(lb); column++; }); grid.Origin = new Point((Game1.self.graphics.PreferredBackBufferWidth - 200) / 2, Game1.self.graphics.PreferredBackBufferHeight - 300); grid.UpdateP(); SetClickables(true); }
public void Fill() { if (fleet != null) { fleet.Ships.ForEach(p => { Card c = new Card(CardWidth, CardHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, p); cardsGrid.AddChild(c); Clickable.Add(c); c.Status = Card.status.clear; c.clickEvent += CardClick; }); } SetClickables(true); Task task = new Task(ReadyFunction); task.Start(); }
public void CardsToRow(List <Ship> ships, Line line, bool allied) { if (allied) { int i; for (i = 0; i < ships.Count; i++) { Card c = ShipToCard(ships[i]); Clickable.Add(c); c.CanMove = true; c.line = line; yourGrid.AddChild(c, i, GetColumn(line, allied)); } while (i < 5) { CardSlot c = new CardSlot(cardWidth, cardHeight, Game1.self.GraphicsDevice, Gui); yourGrid.AddChild(c, i, GetColumn(line, allied)); c.line = line; c.clickEvent += CardSlotClick; Clickable.Add(c); i++; } yourGrid.UpdateP(); } else { for (int i = 0; i < ships.Count; i++) { Card c = ShipToCard(ships[i]); c.line = line; c.Enemy = true; Clickable.Add(c); enemyGrid.AddChild(c, i, GetColumn(line, allied)); } enemyGrid.UpdateP(); } }
public void InitializeBoughtShipsGrid(List <Ship> ships) { int columns = ships.Count; int cardWidth = 133; int cardHeight = 200; BoughtShipsGrid = new Grid(columns, 1, cardWidth, cardHeight); BoxesGrid.DrawBackground = false; BoxesGrid.WitdhAndHeightColumnDependant = false; BoxesGrid.ConstantRowsAndColumns = true; int column = 0; ships.ForEach(p => { Card c = new Card(cardWidth, cardHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, p); Clickable.Add(c); ClickableToRemove.Add(c); c.Active = true; BoughtShipsGrid.AddChild(c, 0, column); column++; }); BoughtShipsGrid.Origin = new Point((Game1.self.graphics.PreferredBackBufferWidth - BoughtShipsGrid.Width) / 2, 300); BoughtShipsGrid.UpdateP(); }
public override void Initialize(ContentManager Content) { Gui = new GUI(Content); BoxesGrid = new Grid(3, 1, (int)(Game1.self.graphics.PreferredBackBufferWidth * 0.3), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.4)); BoxesGrid.DrawBackground = false; BoxesGrid.WitdhAndHeightColumnDependant = false; BoxesGrid.ConstantRowsAndColumns = true; grid = new Grid(); layout = new RelativeLayout(); //grid.DrawBackground = true; grid.Width = 300; grid.Height = 300; grid.Origin = new Point(300, 300); //grid.Origin = new Point((Game1.self.graphics.PreferredBackBufferWidth - 200) / 2, Game1.self.graphics.PreferredBackBufferHeight - 300); //Game1.self.graphics.PreferredBackBufferWidth BoxesGrid.Origin = new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.05), (int)(Game1.self.graphics.PreferredBackBufferWidth * 0.1)); Button exitButton = new Button(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "Back" }; using (var fileStream = Game.Activity.Assets.Open("Icons/Credits.png")) { credits = Texture2D.FromStream(Game1.self.GraphicsDevice, fileStream); fileStream.Dispose(); } g = new Graphic { Scale = new Vector2(60f / credits.Width, 60f / credits.Height), Texture = credits, Position = new Vector2(10, 10) }; popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 100, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); Button b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Ok" }; lbl1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(b1, 1, 0); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); CreditsAmount = new Label(new Point((int)g.Position.X + g.Width + 60, (int)g.Position.Y + g.Height / 2), 100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); CreditsAmount.WidthDerivatingFromText = true; CreditsAmount.HeightDerivatingFromText = true; CreditsAmount.Text = 123412.ToString(); CreditsAmount.InsideColor = new Color(160, 160, 160); CreditsAmount.OutsideColor = new Color(120, 120, 120); layout.AddChild(g, "CreditsIcon"); layout.AddChild(CreditsAmount, "CreditsAmount"); grid.AddChild(exitButton, 0, 0); Clickable.Add(exitButton); exitButton.clickEvent += GoToMenu; grid.UpdateP(); SetClickables(true); }
public override void Initialize(ContentManager Content) { cardWidth = 100; cardHeight = (int)(cardWidth * (200f / 133f)); int columns = (Game1.self.graphics.PreferredBackBufferWidth - 200) / (cardWidth + 5); grid = new Grid(columns, Game1.self.Modifiers.MaxShipsPerPlayer / columns + 1, cardWidth, cardHeight); grid.DrawBorder = true; grid.BorderSize = 3; grid.WitdhAndHeightColumnDependant = false; grid.AllVisible = false; grid.Width = columns * cardWidth + (columns + 1) * grid.columnOffset; grid.Height = 5 * cardHeight + 6 * grid.rowOffset; grid.VisibleRows = 5; grid.ConstantRowsAndColumns = true; grid.MaxChildren = true; grid.ChildMaxAmount = Game1.self.Modifiers.MaxShipsPerPlayer; grid.Origin = new Point(100, 100); Gui = new GUI(Content); layout = new RelativeLayout(); int buttonWidth = 100; int buttonHeight = 50; Button exitButton = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "Exit" }; exitButton.Origin = new Point(grid.Origin.X + grid.Width / 2 - buttonWidth / 2, grid.Origin.Y + grid.Height + 10); exitButton.clickEvent += onExit; Clickable.Add(exitButton); exitButton.Active = true; Button up = new Button(new Point(grid.Origin.X - 60, grid.Origin.Y + grid.Height / 2 - 30), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "up" }; Button down = new Button(new Point(up.Origin.X, up.Origin.Y + 30), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "down" }; layout.AddChild(exitButton); layout.AddChild(up); layout.AddChild(down); up.clickEvent += UpClick; down.clickEvent += DownClick; up.Active = true; down.Active = true; Clickable.Add(up); Clickable.Add(down); #region popup popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 100, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Are you sure you want to dissolve this card for " }; Button b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Cancel" }; Button a1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Dissolve" }; a1.clickEvent += onDissolve; Clickable.Add(a1); lbl1.DrawBackground = false; a1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(a1, 1, 0); popupGrid.AddChild(b1, 1, 1); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); #endregion exitButton.Update(); down.Update(); up.Update(); grid.UpdateP(); }
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(); }
public override void Initialize(ContentManager Content) { ShipsInTop = new List <Card>(); ShipsInBot = new List <Card>(); layout = new RelativeLayout(); Gui = new GUI(Content); Decks = new List <Deck>(); int gridRightColumnWidth = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * (1 - CardGridWidthMulti)) - 30; int gridRightRowHeight = 60; int ColumnWidth = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti * 0.2); int rowHeight = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * CardGridHeightMulti); gridTopLeft = new Grid(5, 3, ColumnWidth, rowHeight); gridRight = new Grid(1, 8, gridRightColumnWidth, gridRightRowHeight); gridRightBottom = new Grid(); int columns = 5; gridCenter = new Grid(columns, Game1.self.Modifiers.MaxShipsPerPlayer / columns + 1, ColumnWidth, rowHeight); ; gridTopLeft.DrawBorder = true; gridRight.DrawBorder = true; gridRightBottom.DrawBorder = false; gridCenter.DrawBorder = true; gridTopLeft.BorderSize = 3; gridRight.BorderSize = 3; gridRightBottom.BorderSize = 3; gridCenter.BorderSize = 3; gridTopLeft.WitdhAndHeightColumnDependant = false; gridRight.WitdhAndHeightColumnDependant = false; gridRightBottom.WitdhAndHeightColumnDependant = false; gridCenter.WitdhAndHeightColumnDependant = false; gridTopLeft.Width = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti); gridRight.Width = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * (1 - CardGridWidthMulti) - 30); gridRightBottom.Width = gridRight.Width; gridCenter.Width = gridTopLeft.Width; gridTopLeft.Height = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * CardGridHeightMulti); gridRight.Height = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * RightGridHeightMulti); gridRightBottom.Height = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * (1 - RightGridHeightMulti) - 30); gridCenter.Height = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * (1 - CardGridHeightMulti) - 30); gridTopLeft.Origin = new Point(10, 10); gridRight.Origin = new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti + 20), 10); gridRightBottom.Origin = new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti + 20), (int)(Game1.self.graphics.PreferredBackBufferHeight * RightGridHeightMulti + 20)); gridCenter.Origin = new Point(10, (int)(Game1.self.graphics.PreferredBackBufferHeight - gridCenter.Height - 10)); Button b = new Button(new Point(0, 0), (int)(gridRightBottom.Width * 0.5 - gridCenter.columnOffset), (int)((gridRightBottom.Height * 0.75) * 0.5 - gridCenter.rowOffset), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Add" }; Button b2 = new Button(new Point(0, 0), (int)(gridRightBottom.Width * 0.5 - gridCenter.columnOffset), (int)((gridRightBottom.Height * 0.75) * 0.5 - gridCenter.rowOffset), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Save" }; Button b3 = new Button(new Point(0, 0), (int)(gridRightBottom.Width * 0.5 - gridCenter.columnOffset), (int)((gridRightBottom.Height * 0.75) * 0.5 - gridCenter.rowOffset), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Remove" }; Button b4 = new Button(new Point(0, 0), (int)(gridRightBottom.Width * 0.5 - gridCenter.columnOffset), (int)((gridRightBottom.Height * 0.75) * 0.5 - gridCenter.rowOffset), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; Button up = new Button(new Point(gridTopLeft.Origin.X + (int)(gridTopLeft.Width) - 60, gridTopLeft.Origin.Y), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "up" }; Button down = new Button(new Point(gridTopLeft.Origin.X + (int)(gridTopLeft.Width) - 60, gridTopLeft.Origin.Y + 30), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "down" }; Button upCenter = new Button(new Point(gridCenter.Origin.X + (int)(gridCenter.Width) - 60, gridCenter.Origin.Y), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "up" }; Button downCenter = new Button(new Point(gridCenter.Origin.X + (int)(gridCenter.Width) - 60, gridCenter.Origin.Y + 30), 60, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "down" }; DeckInputBox = new InputBox(new Point(), gridRightBottom.Width, (int)(gridRightBottom.Height * 0.25), Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false); DeckInputBox.TextLimit = 30; DeckInputBox.BasicText = "Deck name"; up.Update(); down.Update(); upCenter.Update(); downCenter.Update(); up.clickEvent += UpClick; down.clickEvent += DownClick; upCenter.clickEvent += UpClickCenter; downCenter.clickEvent += DownClickCenter; Clickable.Add(up); Clickable.Add(down); Clickable.Add(upCenter); Clickable.Add(downCenter); RelativeLayout rl = new RelativeLayout(); rl.AddChild(up); rl.AddChild(down); rl.AddChild(upCenter); rl.AddChild(downCenter); Clickable.Add(b4); Clickable.Add(DeckInputBox); b4.clickEvent += OnExit; b.clickEvent += OnAdd; b2.clickEvent += OnSave; b3.clickEvent += OnRemove; Clickable.Add(b2); Clickable.Add(b); Clickable.Add(b3); gridRightBottom.AddChild(DeckInputBox, 0, 0, 3); gridRightBottom.AddChild(b, 1, 1); gridRightBottom.AddChild(b2, 1, 2); gridRightBottom.AddChild(b3, 2, 1); gridRightBottom.AddChild(b4, 2, 2); gridRightBottom.ResizeChildren(); DeckInputBox.Update(); layout.AddChild(gridTopLeft); layout.AddChild(gridRight); layout.AddChild(gridRightBottom); layout.AddChild(gridCenter); layout.AddChild(rl); gridTopLeft.AllVisible = false; gridTopLeft.VisibleRows = 1; gridCenter.AllVisible = false; gridCenter.VisibleRows = 5; gridTopLeft.ConstantRowsAndColumns = true; gridTopLeft.MaxChildren = true; gridTopLeft.ChildMaxAmount = 15; gridCenter.ConstantRowsAndColumns = true; gridCenter.MaxChildren = true; gridCenter.ChildMaxAmount = Game1.self.Modifiers.MaxShipsPerPlayer; gridRight.ConstantRowsAndColumns = true; gridRight.MaxChildren = true; gridRight.ChildMaxAmount = 8; cardHeight = gridTopLeft.Height; /* //basic test * * ships = new List<Ship>(); * Random rndRandom = new Random(); * for (int i = 0; i < 30; i++) * { * Ship ship = new Ship(); * ship.Armor = rndRandom.Next(1, 30); * ship.Hp = rndRandom.Next(1, 30); * ships.Add(ship); * } * * List<Ship> Deck1Ships = ships.GetRange(1, 10); * Deck BasicDeck = new Deck(new Point(), 20, (int)(gridRight.Height * 0.1), * Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false, "Basic" ); * Deck1Ships.ForEach(p=> BasicDeck.AddShip(p)); * BasicDeck.clickEvent += DeckClick; * gridRight.AddChild(BasicDeck); * Clickable.Add(BasicDeck); * gridRight.ResizeChildren(); * * */ popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 400, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(popup.Width - 50, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); Button b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; lbl1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(b1, 1, 0); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); FillBotShips(ships); FillBotGrid(); gridTopLeft.AllVisible = false; gridTopLeft.VisibleRows = 1; gridCenter.AllVisible = false; gridCenter.VisibleRows = 5; gridCenter.UpdateP(); gridTopLeft.UpdateP(); }
public override void Initialize(ContentManager Content) { Gui = new GUI(Content); Label labelLogin = new Label(new Point(0, 0), 100, 50, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Login" }; Label labelPassword = new Label(new Point(0, 0), 115, 30, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Password" }; inputLogin = new InputBox(new Point(0, 0), 100, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false); inputLogin.TextLimit = 30; inputLogin.BasicText = "Login"; inputPassword = new InputBox(new Point(0, 0), 100, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false); inputPassword.TextLimit = 30; inputPassword.BasicText = "Password"; Button loginButton = new Button(new Point(0, 0), 105, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Log in" }; Button registerButton = new Button(new Point(0, 0), 105, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Register" }; Button exitButton = new Button(new Point(0, 0), 105, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; #region Popup popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 100, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; lbl1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(b1, 1, 0); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); #endregion inputPassword.IsPassword = true; Clickable.Add(inputLogin); Clickable.Add(inputPassword); Clickable.Add(loginButton); Clickable.Add(registerButton); Clickable.Add(exitButton); grid = new Grid(); grid.AddChild(labelLogin, 0, 0); grid.AddChild(inputLogin, 0, 1, 2); grid.AddChild(labelPassword, 1, 0); grid.AddChild(inputPassword, 1, 1, 2); grid.AddChild(loginButton, 2, 0); grid.AddChild(registerButton, 2, 1); grid.AddChild(exitButton, 2, 2); loginButton.clickEvent += LoginClick; exitButton.clickEvent += ExitClick; registerButton.clickEvent += RegisterClick; grid.ResizeChildren(); SetClickables(true); }
public override void Initialize(ContentManager Content) { Gui = new GUI(Content); Button z = new Button(new Point(100, 200), 120, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Deck" }; Button z2 = new Button(new Point(100, 200), 70, 125, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Settings" }; Button z3 = new Button(new Point(100, 200), 200, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Exit" }; Button p1 = new Button(new Point(100, 200), 120, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Play ranked" }; Button p2 = new Button(new Point(100, 200), 120, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Play custom" }; Button z4 = new Button(new Point(100, 200), 120, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Shop" }; Button z5 = new Button(120, 100, Game1.self.GraphicsDevice, Gui, Gui.bigFont, true) { Text = "Cards" }; z5.clickEvent += goToCards; Clickable.Add(z5); Clickable.Add(p1); Clickable.Add(p2); Clickable.Add(z); Clickable.Add(z2); Clickable.Add(z3); Clickable.Add(z4); grid = new Grid(); lastGamesGrid = new Grid(); lastGamesGrid.Width = 200; lastGamesGrid.Origin = new Point(50, 100); lastGamesGrid.DrawBackground = true; playerStats = new Grid(); grid.AddChild(p1, 0, 0); grid.AddChild(p2, 1, 0); grid.AddChild(z, 2, 0); grid.AddChild(z4, 3, 0); grid.AddChild(z5, 4, 0); grid.AddChild(z3, 6, 0); grid.AddChild(z2, 5, 0); p1.clickEvent += Play; p2.clickEvent += PlayCustom; z3.clickEvent += ExitClick; z4.clickEvent += GoToShop; z.clickEvent += GoToDeck; z2.clickEvent += GoToSettings; grid.Origin = new Point((int)(Game1.self.GraphicsDevice.Viewport.Bounds.Width / 2.0f - grid.Width / 2.0f), (int)(Game1.self.GraphicsDevice.Viewport.Bounds.Height / 2.0f - grid.Height / 2.0f)); grid.UpdateP(); playerStats.Origin = new Point(grid.Origin.X + grid.Width + 10, grid.Origin.Y); playerStats.UpdateP(); grid.ResizeChildren(); SetClickables(true); }
public void PlayCustom() { int topOrigin = (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.2); int buttonWidth = 200; int leftOffset = 10; int leftOrigin = (int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5 - (2 * buttonWidth + leftOffset * 1.5)); int topOffset = 10; int buttonHeight = 50; ClickableToRemove = new List <IClickable>(); RelativeLayout layout = new RelativeLayout(); nameInputBox = new InputBox(new Point(leftOrigin + leftOffset, topOrigin + topOffset), 2 * buttonWidth, 2 * buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { TextLimit = 30, BasicText = "Room name" }; creatornameInputBox = new InputBox(new Point(leftOrigin + leftOffset, nameInputBox.Origin.Y + nameInputBox.Height + topOffset), 2 * buttonWidth, 2 * buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { TextLimit = 30, BasicText = "Creator name" }; Clickable.Add(nameInputBox); ClickableToRemove.Add(nameInputBox); Clickable.Add(creatornameInputBox); ClickableToRemove.Add(creatornameInputBox); Join = new Button(new Point(nameInputBox.Origin.X, creatornameInputBox.Origin.Y + creatornameInputBox.Height + topOffset), buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Join" }; Join.clickEvent += onJoin; Clickable.Add(Join); ClickableToRemove.Add(Join); Create = new Button(new Point(Join.Origin.X + buttonWidth, Join.Origin.Y), buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Create" }; Create.clickEvent += onCreate; Clickable.Add(Create); ClickableToRemove.Add(Create); labelError = new Label(new Point(nameInputBox.Origin.X + nameInputBox.Width + leftOffset, nameInputBox.Origin.Y), buttonWidth * 2, buttonHeight * 3, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "To create room write the name and click Create button, to join room write it's name and click Join button." + " To join you have also to write creator's name." }; Button Exit = new Button(new Point(labelError.Origin.X, labelError.Origin.Y + labelError.Height + topOffset), buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; Exit.clickEvent += onExitCustom; Clickable.Add(Exit); ClickableToRemove.Add(Exit); up = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "up" }; up.Origin = new Point(nameInputBox.Origin.X, Join.Origin.Y + Join.Height + topOffset); up.clickEvent += upClick; Clickable.Add(up); ClickableToRemove.Add(up); down = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "down" }; down.clickEvent += downClick; Clickable.Add(down); ClickableToRemove.Add(down); g = new Grid(1, 8, buttonWidth, buttonHeight); g.Origin = new Point(Join.Origin.X, up.Origin.Y + up.Height + topOffset); g.AllVisible = false; g.MaxChildren = true; g.ChildMaxAmount = 8; g.VisibleRows = 5; Game1.self.Decks.ForEach(p => { Deck d = new Deck(new Point(0, 0), buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, p.Name); d.SetFleet(p); d.clickEvent += DeckClick; d.ActiveChangeable = true; Clickable.Add(d); ClickableToRemove.Add(d); g.AddChild(d); }); g.WitdhAndHeightColumnDependant = false; g.ConstantRowsAndColumns = true; g.UpdateP(); ; Point downPoint = new Point(leftOrigin + leftOffset, g.Origin.Y + (int)g.RowOffset(5) + 10); down.Origin = downPoint; Exit.Origin = new Point(Exit.Origin.X, down.Origin.Y); layout.AddChild(creatornameInputBox); layout.AddChild(nameInputBox); layout.AddChild(Join); layout.AddChild(Create); layout.AddChild(labelError); layout.AddChild(Exit); layout.AddChild(g); layout.AddChild(up); layout.AddChild(down); popup = new Popup(new Point(leftOrigin, topOrigin), 4 * buttonWidth + leftOffset * 3, 7 * buttonHeight + topOffset * 7 + (int)g.RowOffset(5), Game1.self.GraphicsDevice, Gui); popup.layout = layout; nameInputBox.Update(); creatornameInputBox.Update(); g.UpdateP(); Join.Update(); Create.Update(); labelError.Update(); Exit.Update(); up.Update(); down.Update(); ; popup.SetBackground(); Game1.self.popupToDraw = popup; SetClickables(false); popup.SetActive(true); popup.layout.UpdateActive(true); Join.Active = false; Create.Active = false; }
public void Play() { ClickableToRemove = new List <IClickable>(); int leftOffset = 10; int topOffset = 10; int buttonWidth = 200; int buttonHeight = 50; int topOrigin = (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.3); int leftOrigin = (int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5 - (buttonWidth + 10)); Point popupOrigin = new Point(leftOrigin, topOrigin); RelativeLayout layout = new RelativeLayout(); up = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "up" }; up.Origin = new Point(leftOrigin + leftOffset, topOrigin + topOffset); up.clickEvent += upClick; Clickable.Add(up); ClickableToRemove.Add(up); down = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "down" }; exit = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "exit" }; search = new Button(buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "search game" }; search.ActiveChangeable = false; search.clickEvent += searchClick; Clickable.Add(search); ClickableToRemove.Add(search); exit.clickEvent += exitClick; Clickable.Add(exit); ClickableToRemove.Add(exit); down.clickEvent += downClick; Clickable.Add(down); ClickableToRemove.Add(down); g = new Grid(1, 8, buttonWidth, buttonHeight); g.Origin = new Point(leftOrigin + leftOffset, up.Origin.Y + up.Height + 10); g.AllVisible = false; g.MaxChildren = true; g.ChildMaxAmount = 8; g.VisibleRows = 5; Game1.self.Decks.Where(a => a.Ships.Count > 0).ToList().ForEach(p => { Deck d = new Deck(new Point(), buttonWidth, buttonHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, p.Name); d.SetFleet(p); d.clickEvent += DeckClick; d.ActiveChangeable = true; Clickable.Add(d); ClickableToRemove.Add(d); g.AddChild(d); }); g.WitdhAndHeightColumnDependant = false; g.ConstantRowsAndColumns = true; g.UpdateP(); Point downPoint = new Point(leftOrigin + leftOffset, g.Origin.Y + (int)g.RowOffset(5) + 10); down.Origin = downPoint; exit.Origin = new Point(down.Origin.X + 10 + buttonWidth, down.Origin.Y); search.Origin = new Point(exit.Origin.X, exit.Origin.Y - buttonHeight - 10); labelWaiting = new Label(buttonWidth, buttonHeight * 2, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); labelWaiting.Text = initialText; time = 0; labelWaiting.Origin = new Point(up.Origin.X + buttonWidth + 10, up.Origin.Y); layout.AddChild(up); layout.AddChild(down); layout.AddChild(g); layout.AddChild(exit); layout.AddChild(search); layout.AddChild(labelWaiting); popup = new Popup(popupOrigin, 2 * buttonWidth + 30, topOffset + up.Height + (int)g.RowOffset(5) + 10 + down.Height + 10 + 10, Game1.self.GraphicsDevice, Gui); popup.layout = layout; up.Update(); down.Update(); exit.Update(); search.Update(); g.UpdateP(); labelWaiting.Update(); popup.SetBackground(); Game1.self.popupToDraw = popup; SetClickables(false); popup.SetActive(true); popup.layout.UpdateActive(true); search.Active = false; }
public override void Initialize(ContentManager Content) { Gui = new GUI(Content); layout = new RelativeLayout(); double cardWidthPercentage = 0.25; double cardHeightPercentage = 0.18; double widthPercentage = 0.2; double heightPercentage = 0.95; int ColumnWidth = (int)(Game1.self.graphics.PreferredBackBufferWidth * widthPercentage * cardWidthPercentage); int RowHeight = (int)(Game1.self.graphics.PreferredBackBufferHeight * heightPercentage * cardHeightPercentage); enemyGrid = new Grid(3, 5, ColumnWidth, RowHeight); yourGrid = new Grid(3, 5, ColumnWidth, RowHeight); move = new Move(); #region Popup popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 100, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; lbl1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(b1, 1, 0); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); #endregion enemyGrid.WitdhAndHeightColumnDependant = false; yourGrid.WitdhAndHeightColumnDependant = false; enemyGrid.Width = (int)(Game1.self.graphics.PreferredBackBufferWidth * widthPercentage); yourGrid.Width = (int)(Game1.self.graphics.PreferredBackBufferWidth * widthPercentage); enemyGrid.Height = (int)(Game1.self.graphics.PreferredBackBufferHeight * heightPercentage); yourGrid.Height = (int)(Game1.self.graphics.PreferredBackBufferHeight * heightPercentage); enemyGrid.DrawBorder = true; yourGrid.DrawBorder = true; enemyGrid.BorderSize = 3; yourGrid.BorderSize = 3; enemyGrid.rowOffset = (int)(enemyGrid.Height * 0.025); yourGrid.rowOffset = (int)(enemyGrid.Height * 0.025); enemyGrid.columnOffset = (int)(enemyGrid.Width * 0.125); yourGrid.columnOffset = (int)(yourGrid.Width * 0.125); yourGrid.Origin = new Point(10, 10); enemyGrid.Origin = new Point(Game1.self.graphics.PreferredBackBufferWidth - 10 - enemyGrid.Width, 10); turnButton = new Button(enemyGrid.Origin.X - (yourGrid.Origin.X + (int)yourGrid.Width) - 40, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "End turn" }; turnButton.Origin = new Point(yourGrid.Origin.X + (int)yourGrid.Width + 20, yourGrid.Origin.Y + yourGrid.Height / 2 - turnButton.Height / 2); turnButton.clickEvent += EndTurnClick; Clickable.Add(turnButton); timeLabel = new Label(new Point(turnButton.Origin.X, turnButton.Origin.Y - turnButton.Height - 10), turnButton.Width, turnButton.Height, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true); cardWidth = (int)(yourGrid.Width * cardWidthPercentage); cardHeight = (int)(yourGrid.Height * cardHeightPercentage); layout.AddChild(enemyGrid); layout.AddChild(yourGrid); layout.AddChild(turnButton); layout.AddChild(timeLabel); layout.Update(); }
public override void Initialize(ContentManager Content) { Gui = new GUI(Content); registerButton = new Button(new Point(0, 0), 120, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "Register" }; Button backButton = new Button(new Point(0, 0), 100, 45, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { text = "Back" }; Label loginLabel = new Label(new Point(0, 0), 120, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Login" }; Label passwordLabel = new Label(new Point(0, 0), 120, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Password" }; Label passwordLabel2 = new Label(new Point(0, 0), 120, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Password again" }; loginInputBox = new InputBox(new Point(0, 0), 300, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false) { TextLimit = 30, BasicText = "Login" }; passwordInputBox = new InputBox(new Point(0, 0), 300, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false) { TextLimit = 30, BasicText = "Password" }; passwordInputBox2 = new InputBox(new Point(0, 0), 300, 60, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, false) { TextLimit = 30, BasicText = "Password" }; Tooltip tooltipLogin = new Tooltip(200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, 150) { Text = "Maximum 30 characters" }; Tooltip tooltipPassword1 = new Tooltip(200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, 150) { Text = "Maximum 30 characters" }; Tooltip tooltipPassword2 = new Tooltip(200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, 150) { Text = "Write your password once again." }; loginInputBox.Tooltip = tooltipLogin; passwordInputBox.Tooltip = tooltipPassword1; passwordInputBox2.Tooltip = tooltipPassword2; passwordInputBox.IsPassword = true; passwordInputBox2.IsPassword = true; #region popup popup = new Popup(new Point((int)(Game1.self.graphics.PreferredBackBufferWidth * 0.5), (int)(Game1.self.graphics.PreferredBackBufferHeight * 0.5)), 100, 400, Game1.self.GraphicsDevice, Gui); Grid popupGrid = new Grid(); lbl1 = new Label(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Both passwords must be the same" }; Button b1 = new Button(100, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true) { Text = "Exit" }; b1.Active = false; lbl1.DrawBackground = false; b1.DrawBackground = false; popup.grid = popupGrid; popupGrid.AddChild(lbl1, 0, 0); popupGrid.AddChild(b1, 1, 0); b1.clickEvent += onPopupExit; Clickable.Add(b1); popup.SetToGrid(); #endregion Clickable.Add(registerButton); Clickable.Add(backButton); Clickable.Add(loginInputBox); Clickable.Add(passwordInputBox); Clickable.Add(passwordInputBox2); grid = new Grid(); grid.AddChild(loginLabel, 0, 0); grid.AddChild(passwordLabel, 1, 0); grid.AddChild(passwordLabel2, 2, 0); grid.AddChild(loginInputBox, 0, 1); grid.AddChild(passwordInputBox, 1, 1); grid.AddChild(passwordInputBox2, 2, 1); grid.AddChild(registerButton, 3, 0); grid.AddChild(backButton, 3, 1); backButton.clickEvent += backClick; registerButton.clickEvent += registerClick; grid.Origin = new Point((int)(Game1.self.GraphicsDevice.Viewport.Bounds.Width / 2.0f - grid.Width / 2.0f), (int)(Game1.self.GraphicsDevice.Viewport.Bounds.Height / 2.0f - grid.Height / 2.0f)); grid.UpdateP(); grid.ResizeChildren(); SetClickables(true); }