public void GenerarGridAttack() { for (int count = 0; count < GlobalVar.friendCoach.user.pokemons[GlobalVar.pokAmigo].moves.Count(); count++) { switch (count) { case 0: GlobalGrid.buttonAttack1.Text = GlobalVar.friendMoves[count].name; break; case 1: GlobalGrid.buttonAttack2.Text = GlobalVar.friendMoves[count].name; break; case 2: GlobalGrid.buttonAttack3.Text = GlobalVar.friendMoves[count].name; break; case 3: GlobalGrid.buttonAttack4.Text = GlobalVar.friendMoves[count].name; break; default: break; } } GlobalGrid.buttonAttack1.Clicked += Button_click; GlobalGrid.buttonAttack2.Clicked += Button_click; GlobalGrid.buttonAttack3.Clicked += Button_click; GlobalGrid.buttonAttack4.Clicked += Button_click; async void Button_click(Object sender, EventArgs e) { Button boton = (Button)sender; if (GlobalVar.friendCoach.user.pokemons[GlobalVar.pokAmigo].moves.Count() > int.Parse(boton.StyleId)) { await GlobalLogic.AtaqueAsync(int.Parse(boton.StyleId), true); if (GlobalVar.enemyCoach.user.pokemons[GlobalVar.pokEnemigo].hp == 0) { await GlobalLogic.actualizarExperienciaAsync(); } else { await GlobalLogic.AtaqueAsync(new Random(DateTime.Now.Millisecond).Next(0, GlobalVar.enemyCoach.user.pokemons[GlobalVar.pokEnemigo].moves.Count()), false); if (GlobalVar.friendCoach.user.pokemons[GlobalVar.pokAmigo].hp == 0) { while (CargarPokemonsThread.IsAlive) { Java.Lang.Thread.Sleep(1); } Device.BeginInvokeOnMainThread(async() => { await Navigation.PushAsync(new SelectPage()); }); } } } } }