//evento que regresa al menu principal estando en el Game Form private void BtnBack_Click(object sender, EventArgs e) { var menuForm = new Menu(); menuForm.Show(); Dispose(); }
//Funcion encargada de generar todos los loads del juego private void Loading() { //Instanciacion del ArkanoidControl ac = new ArkanoidControl { Dock = DockStyle.Fill, Width = Width, Height = Height }; //Action GameEnded que vuelve al menu al terminar el juego ac.GameEnded = () => { MessageBox.Show("PERDISTE"); var menuForm = new Menu(); menuForm.Show(); Dispose(); }; //Action GameWon que vuelve al menu al ganar la partida y guarda los datos del ganador ac.GameWon = () => { var id = DBConnetion.RealizarConsulta($"select id from users where name='{TxtName.Text}'").Rows[0][0]. ToString(); var maximo = DBConnetion.RealizarConsulta($"select attempt from attempts" + $" where id_user = '******' ORDER BY attempt DESC FETCH FIRST 1 ROWS ONLY"); int val; if (maximo.Rows.Count == 0) { val = 1; } else { val = Convert.ToInt32(maximo.Rows[0][0].ToString()) + 1; } DBConnetion.RealizarAccion($"INSERT into ATTEMPTS(id_user,attempt,score) VALUES('{Convert.ToInt32(id)}', {val},{GameData.score})"); MessageBox.Show("GANASTE LA PARTIDA"); var menuForm = new Menu(); menuForm.Show(); Dispose(); }; }