private void BttnStartGame_Click(object sender, EventArgs e) { GameData.InitializeGame(); // Instanciacion y preparacion de UserControl ca = new ControlArkanoid { Dock = DockStyle.Fill, Width = Width, Height = Height }; // Seteo de Delegate que maneja el fin del juego ca.FinishGame = () => { MessageBox.Show("Has perdido"); ca.Hide(); tableLayoutPanel1.Show(); }; // Seteo de Delegate que maneja cuando se gana el juego ca.WinningGame = () => { PlayerController.CreateNewScore(currentPlayer.idPlayer, GameData.score); MessageBox.Show("Has ganado!"); ca.Hide(); tableLayoutPanel1.Show(); }; tableLayoutPanel1.Hide(); FormRegister fr = new FormRegister(); fr.gn = (string nick) => { if (PlayerController.CreatePlayer(nick)) { MessageBox.Show($"Bienvenido nuevamenete {nick}"); } else { MessageBox.Show($"Gracias por registrarte {nick}"); } currentPlayer = new Player(nick, 0); fr.Dispose(); }; fr.Show(); Controls.Add(ca); }
private void Form1_Load(object sender, EventArgs e) { MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, Height); tableLayoutPanel1.BackColor = Color.Transparent; BackgroundImage = Image.FromFile("../../Img/bg.png"); BackgroundImageLayout = ImageLayout.Stretch; ca = new ControlArkanoid(); ca.Dock = DockStyle.Fill; ca.Width = Width; ca.Height = Height; ca.FinishGame = () => { ca = null; ca = new ControlArkanoid(); MessageBox.Show("Has perdido"); ca.Hide(); tableLayoutPanel1.Show(); }; }