Esempio n. 1
0
 //KMZWA8AWAA
 /// <summary>
 /// Constructor de la clase Juego
 /// </summary>
 /// <param name="mapas">Lista de mapas que se usaran en el juego</param>
 /// <param name="dificultad">Dificultad de juego</param>
 /// <param name="jugador">Datos del jugador</param>
 /// <param name="entradaVoz">Vaor booleano que indica el metodo de entrada del juego (Voz o teclado)</param>
 /// <param name="vidasPac">Vidas del jugador</param>
 /// <param name="hpPac">Valor de cada vida del Jugador</param>
 public Juego(Mapa mapa, String dificultad, DatosJugador jugador, Boolean entradaVoz, int vidasPac, int hpPac)
 {
     //this.listaDeMapaslvl1 = new List<Mapa>();
     //this.listaDeMapaslvl2 = new List<Mapa>();
     //this.listaDeMapaslvl3 = new List<Mapa>();
     this.mapaActual = mapa;
     this.fantasmasLvl1 = new List<Fantasma>();
     //this.fantasmasLvl2 = new List<Fantasma>();
     //this.fantasmasLvl3 = new List<Fantasma>();
     //this.separarMapasPorNivel(mapas);
     this.dificultad = dificultad;
     this.datosJugador = jugador;
     this.entradaPorVoz = entradaVoz;
     this.nivelActual = 1;
     this.r = new Random();
     this.configurarJuego(vidasPac, hpPac);
     this.estadoDelJuego = true;
     this.jugando = 1;
     this.tiempoFantasmasVulnerables = 0;
     this.tiempoAumentoVel = 0;
     this.tiempoFrutilla = 0;
     this.tiempoFrutaViva = 0;
     this.segundos = 0;
     this.iFrut = -1;
     this.jFrut = -1;
 }
 private void btnAceptarConfigInicial_Click(object sender, EventArgs e)
 {
     if (txtNombreJu.Text != null && cmbSeleccionarDificultad.SelectedIndex > -1) {
         nuevoJugador = new DatosJugador(txtNombreJu.Text);
         dificultad = cmbSeleccionarDificultad.SelectedItem.ToString();
         if (rBtnVoz.Checked) {
             entradaPorVoz = true;
         } else {
             entradaPorVoz = false;
         }
         this.Visible = false;
     } else {
         MessageBox.Show("No hay nombre o nivel de dificultad seleccionado");
     }
 }
        private void btnAceptarConfigInicial_Click(object sender, EventArgs e)
        {
            if (txtNombreJu.Text != null && cmbSeleccionarDificultad.SelectedIndex > -1) {
                String dificultad = cmbSeleccionarDificultad.SelectedItem.ToString();
                DatosJugador nuevoJugador = new DatosJugador(txtNombreJu.Text, dificultad);
                Boolean entradaPorVoz;
                if (rBtnVoz.Checked) {
                    entradaPorVoz = true;
                } else {
                    entradaPorVoz = false;
                }

                if (dificultad == "Facil") {
                    juego = new Juego(listadeMapasFacil, dificultad, nuevoJugador, entradaPorVoz, (int)nudVidasPacman.Value, (int)nudHPPacman.Value);
                } else if (dificultad == "Medio") {
                    juego = new Juego(listadeMapasMedio, dificultad, nuevoJugador, entradaPorVoz, (int)nudVidasPacman.Value, (int)nudHPPacman.Value);
                } else if (dificultad == "Dificil") {
                    juego = new Juego(listadeMapasDificil, dificultad, nuevoJugador, entradaPorVoz, (int)nudVidasPacman.Value, (int)nudHPPacman.Value);

                }

                VistaJuego vj = new VistaJuego();
                vj.definirEntrada(entradaPorVoz);
                if (entradaPorVoz) {
                    vj.iniciarReconocedor();
                }
                vj.crearJuego(this.juego);
                DialogResult res = vj.ShowDialog();

                if (res == DialogResult.OK) {
                    carYReproducir();
                    DatosJugador jugadorEntrante = vj.Juego.DatosJugador;
                    jugadorEntrante.Fecha = DateTime.Now.ToString();
                    this.datosJugadores.Add(jugadorEntrante);
                    this.ordenarDescendente();
                    this.panelConfigInicio.Visible = false;
                    this.panelPuntajes.Visible = true;
                    this.listarDatosJugadores();
                    this.cargarMapas();
                }
            } else {
                MessageBox.Show("No hay nombre o nivel de dificultad seleccionado");
            }
        }