Ejemplo n.º 1
0
        private async void Jugar()
        {
            this.Cursor = Cursors.WaitCursor;
            btnLimpiarBarcos.Enabled  = false;
            btnIniciarBatalla.Enabled = false;
            Estrategia juego = new Estrategia(tableroA, tableroB);

            while (juego.aciertosJugador1 < 40 && juego.aciertosJugador2 < 40)
            {
                await Task.Delay(60);

                juego.TiroRandom();
                lblAciertosA.Text  = juego.aciertosJugador1.ToString();
                lblCantTirosA.Text = juego.cantTirosJugador1.ToString();

                juego.TiroCaza();
                lblAciertosB.Text  = juego.aciertosJugador2.ToString();
                lblCantTirosB.Text = juego.cantTirosJugador2.ToString();

                if (juego.aciertosJugador1 == 40)
                {
                    lblGanadorA.Visible = true;
                }
                else if (juego.aciertosJugador2 == 40)
                {
                    lblGanadorB.Visible = true;
                }
            }
            btnLimpiarBarcos.Enabled = true;

            this.Cursor = Cursors.Arrow;
        }
Ejemplo n.º 2
0
        private void Jugar()
        {
            Estrategia juego = new Estrategia(tableroA, tableroB);

            while (juego.aciertosJugador1 < 40 && juego.aciertosJugador2 < 40)
            {
                juego.TiroRandom();

                juego.TiroCaza();

                if (juego.aciertosJugador1 == 40)
                {
                    cantGanados1++;
                }
                else if (juego.aciertosJugador2 == 40)
                {
                    cantGanados2++;
                }
            }
        }