Пример #1
0
        private void detenerCombate(bool preguntarPorGanador)
        {
            subsistemaTiempo.terminarCombate();
            if (preguntarPorGanador) //si se recibe el parametro como true, se pregunta si se desea determinar al ganador automáticamente
            {
                //preguntar si se desea establecer automáticamente al ganador.
                if (MessageBox.Show("¿Determinar ganador automáticamente?", "Combate finalizado", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    determinarGanador();
                }
                else
                {
                    //mostrar form de ganador manual
                    DeterminarGanador ganador = new DeterminarGanador();
                    if (ganador.ShowDialog() == DialogResult.OK)
                    {
                        int win = ganador.ganador;
                        if (win == Punteo.AZUL)
                            ganadorAzul();
                        else if (win == Punteo.ROJO)
                            ganadorRojo();
                    }
                    else
                        groupGanador.Enabled = true;
                }
            }
            else //sino, simplemente se determina automáticamente
                determinarGanador();

            botonDetenerCombate.Enabled = false;
            botonNuevoCombate.Enabled = true;
            botonPlay.Enabled = false;
            botonPausa.Enabled = false;
            botonStop.Enabled = false;
            botonAdelantar.Enabled = false;
            botonAtrasar.Enabled = false;
            groupAmonestaciones.Enabled = false;
            //groupGanador.Enabled = false;
            groupPuntos.Enabled = false;
        }
Пример #2
0
        private void timerPrincipal_Tick(object sender, EventArgs e)
        {
            //encender el reloj de control y de mostrado
            timerPrincipal.Enabled = subsistemaTiempo.reloj();
            //actualizar los mensajes mostrados
            lblTiempo.Text = subsistemaTiempo.tiempo;
            lblRound.Text = subsistemaTiempo.round;
            //si el timer no se activó determinar si terminó el combate o se terminó el round o se terminó el tiempo médico
            if (timerPrincipal.Enabled == false)
            {
                if (subsistemaTiempo.detenido == false) //si el tiempo no se ha puesto en pausa general, de lo contrario no se hace nada
                {
                    //si el tiempo médico estaba activado
                    if (subsistemaTiempo.enPausa == true)
                    {
                        detenerClicSostenido(); //detener clic sostenido por si se llegó a cero
                        botonPlay.Enabled = false;
                        
                        //se reinicia el timer y el subsistema de tiempo
                        timerPrincipal.Enabled = subsistemaTiempo.reiniciarDeTiempoMedico();
                        //actualizar las etiquetas
                        lblTiempo.Text = subsistemaTiempo.tiempo;
                        lblRound.Text = subsistemaTiempo.round;
                    }
                    else if (subsistemaTiempo.roundTerminado == true) //si el round terminó
                    {
                        if ((subsistemaTiempo.combateTerminado == true) && (subsistemaTiempo.muerteSubita == false)) //si el combate ya terminó y no está en muerte súbita
                        {
                            if (subsistemaPuntos.empate == true) //si hay un empate
                            {
                                if (subsistemaTiempo.enDescanso == true)
                                {
                                    subsistemaTiempo.finalizarDescanso();
                                    //en los subsistemas de puntos y tiempo se inicia la muerte súbita
                                    subsistemaPuntos.iniciarMuerteSubita();
                                    subsistemaTiempo.iniciarMuerteSubita();
                                    //se actualiza toda la información mostrada
                                    lblTiempo.Text = subsistemaTiempo.tiempo;
                                    lblRound.Text = subsistemaTiempo.round;
                                    lblAzul.Text = subsistemaPuntos.puntosAzul;
                                    lblRojo.Text = subsistemaPuntos.puntosRojo;

                                    for (int i = 0; i < subsistemaPuntos.amonestaciones; i++)
                                    {
                                        gamAzul[i].BackgroundImage = picNoMarcada.BackgroundImage;
                                        gamAzul[i].BackgroundImageLayout = picMuestra.BackgroundImageLayout;
                                        gamAzul[i].Size = tamanioStandar;
                                        gamAzul[i].Visible = true;

                                        gamRojo[i].BackgroundImage = picNoMarcada.BackgroundImage;
                                        gamRojo[i].BackgroundImageLayout = picMuestra.BackgroundImageLayout;
                                        gamRojo[i].Size = tamanioStandar;
                                        gamRojo[i].Visible = true;
                                    }

                                    MessageBox.Show("Iniciar muerte súbita", "Iniciar round", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    timerPrincipal.Enabled = true;
                                }
                                else
                                {
                                    //preguntar si se desea un round de desempate
                                    if (MessageBox.Show("¿Iniciar round de desempate?", "Empate", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        detenerClicSostenido(); //detener el timer del clic sostenido porque cuando se llega a cero, el evento mouseUp no funciona.
                                        //esperar la confirmación del usuario para iniciar el siguiente round
                                        MessageBox.Show("Iniciar descanso", "Iniciar descanso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        subsistemaTiempo.tiempoDescansoDesempate = true;
                                        subsistemaTiempo.combateTerminado = false;
                                        subsistemaTiempo.iniciarDescanso();
                                        timerPrincipal.Enabled = true;
                                        lblTiempo.Text = subsistemaTiempo.tiempo;
                                        lblRound.Text = subsistemaTiempo.round;
                                    }
                                    else //si el usuario respondió que no quiere determinar automáticamente al ganador, mostrar el formulario para determinar manualmente al ganador
                                    {
                                        DeterminarGanador ganador = new DeterminarGanador();
                                        if (ganador.ShowDialog() == DialogResult.OK)
                                        {
                                            int win = ganador.ganador;
                                            if (win == Punteo.AZUL)
                                                ganadorAzul();
                                            else if (win == Punteo.ROJO)
                                                ganadorRojo();
                                        }
                                        else
                                            groupGanador.Enabled = true;
                                    }
                                }
                            }
                            else //si no hay empate, se determina al ganador automáticamente
                            {
                                detenerCombate(true);
                            }
                        }
                        else if ((subsistemaTiempo.combateTerminado == true) && (subsistemaTiempo.muerteSubita == true)) //si el combate terminó y estaba en muerte subita
                        {
                            //preguntar por quién va ganar
                            detenerCombate(true);
                        }
                        else //si el combate no ha terminado, pero sí el round
                        {
                            if (subsistemaTiempo.enDescanso == true)
                            {
                                detenerClicSostenido(); //detener el timer del clic sostenido porque cuando se llega a cero, el evento mouseUp no funciona.
                                //esperar la confirmación del usuario para iniciar el siguiente round
                                MessageBox.Show("Iniciar siguiente round", "Iniciar round", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                subsistemaTiempo.finalizarDescanso();
                                timerPrincipal.Enabled = subsistemaTiempo.iniciar();
                                lblTiempo.Text = subsistemaTiempo.tiempo;
                                lblRound.Text = subsistemaTiempo.round;
                            }
                            else
                            {
                                detenerClicSostenido(); //detener el timer del clic sostenido porque cuando se llega a cero, el evento mouseUp no funciona.
                                //esperar la confirmación del usuario para iniciar el siguiente round
                                MessageBox.Show("Iniciar descanso", "Iniciar descanso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                subsistemaTiempo.iniciarDescanso();
                                timerPrincipal.Enabled = true;
                                lblTiempo.Text = subsistemaTiempo.tiempo;
                                lblRound.Text = subsistemaTiempo.round;
                            }

                            
                        }
                    }
                }
            }
        }