public void GetLootbox(object sender) { LootBoxElement el = (LootBoxElement)sender; GamePacket packet = new GamePacket(OperationType.BUY, el.Lootbox); Game1.self.Connection.Send(packet); packet = Game1.self.Connection.GetReceivedPacket(); if (packet.OperationType == OperationType.SUCCESS) { packet = Game1.self.Connection.GetReceivedPacket(); if (packet.OperationType == OperationType.BOUGHT_SHIPS) { List <Ship> ships = (List <Ship>)packet.Packet; InitializeBoughtShipsGrid(ships); state = State.cards; Game1.self.UpdatePlayer(); SetMoney(Game1.self.player.Money); BoxesGrid.UpdateActive(false); BoughtShipsGrid.UpdateActive(true); } else { } } else { lbl1.Text = packet.Packet.ToString(); popup.SetActive(true); Game1.self.popupToDraw = popup; SetClickables(false); } }
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); }