예제 #1
0
        private void TimerPunteo_Tick(object sender, EventArgs e)
        {
            //Algoritmo para dar marcha al tiempo de juego.
            int tiempoRestante = int.Parse(LblTiempoRestante.Text);

            tiempoRestante--;
            LblTiempoRestante.Text = tiempoRestante.ToString();

            //Al faltar 15 segundos de juego, el color del texto de la etiqueta se vuelve rojo.
            if (LblTiempoRestante.Text == "15")
            {
                LblTiempoRestante.ForeColor = Color.Red;
            }

            //Detiene todo al terminar el tiempo.
            if (LblTiempoRestante.Text == "0")
            {
                TimerCarros.Stop();
                TimerPunteo.Stop();
                MessageBox.Show("Se acabó el tiempo, inténtalo de nuevo.", "Fin del juego");
            }

            //Validación para cambiar la cantidad de ancianos restantes.
            if (anciano1.Location.Y < 58)
            {
                LblAncianos.Text = "1";
            }

            //Validación para cambiar la cantidad de ancianos restantes.
            if (anciano2.Location.Y < 58)
            {
                LblAncianos.Text = "0";
            }

            //Validación para cambiar la cantidad de mascotas restantes.
            if (mascota1.Location.Y < 58)
            {
                LblMascotas.Text = "0";
            }

            //Validación para ganar el juego.
            if (LblAncianos.Text == "0" && LblMascotas.Text == "0")
            {
                TimerPunteo.Stop();
                TimerCarros.Stop();
                MessageBox.Show("¡Felicidades! Has ganado el nivel fácil.", "Nivel superado");
            }
        }
예제 #2
0
 public JuegoFacil()
 {
     InitializeComponent();
     TimerCarros.Start();
     TimerPunteo.Start();
 }