public static void AddJugador(Jugador jugador)
 {
     jugadores.Add(jugador);
 }
Esempio n. 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            score.Text       = "Tu Puntaje es :" + Convert.ToString(puntaje);
            nombreUsser.Text = "Hola" + " " + nombre;

            if (goleft)
            {
                pacman.Left       -= speed;
                FantasmaRojo.Left -= fantasma1;
                FantasmaRosa.Left -= fantasma2;
            }
            if (goright)
            {
                pacman.Left       += speed;
                FantasmaRojo.Left += fantasma1;
                FantasmaRosa.Left += fantasma2;
            }
            if (goup)
            {
                pacman.Top       -= speed;
                FantasmaRojo.Top -= fantasma1;
                FantasmaRosa.Top -= fantasma2;
            }
            if (godown)
            {
                pacman.Top       += speed;
                FantasmaRojo.Top += fantasma1;
                FantasmaRosa.Top += fantasma2;
            }
            foreach (Control x in this.Controls)
            {
                if (x is PictureBox && x.Name == "wall1" || x.Name == "wall2" || x.Name == "wall3" || x.Name == "paredIzq" || x.Name == "paredDer" || x.Name == "ParedDown" || x.Name == "paredUp")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(FantasmaRojo.Bounds))
                    {
                        fantasma1 = -fantasma1;
                    }
                }
            }
            foreach (Control x in this.Controls)
            {
                if (x is PictureBox && x.Name == "wall1" || x.Name == "wall2" || x.Name == "wall3" || x.Name == "paredIzq" || x.Name == "paredDer" || x.Name == "ParedDown" || x.Name == "paredUp")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(FantasmaRosa.Bounds))
                    {
                        fantasma2 = -fantasma2;
                    }
                }
            }

            foreach (Control x in this.Controls)
            {
                if (x is PictureBox && x.Name == "wall1" || x.Name == "wall2" || x.Name == "wall3" || x.Name == "paredIzq" || x.Name == "paredDer" || x.Name == "ParedDown" || x.Name == "paredUp" || x.Name == "FantasmaRojo" || x.Name == "FantasmaRosa")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(pacman.Bounds))
                    {
                        pacman.Left = 156;
                        pacman.Top  = 226;
                        gameover.Show();
                        derrota.Show();
                        datosfinales.Text = "Tu puntaje" + " " + nombre + " " + "es :" + " " + puntaje.ToString();
                        datosfinales.Show();
                        Jugador jugador = new Jugador(nombre, puntaje);
                        BBDD.AddJugador(jugador);
                        timer.Interval = 5000;
                        timer.Tick    += new EventHandler(timer_Tick);
                        timer.Start();
                        timer1.Stop();
                    }
                }
                if (x is PictureBox && x.Name == "coin" || x.Name == "coin1" || x.Name == "coin2" || x.Name == "coin3" || x.Name == "coin4" || x.Name == "coin5" || x.Name == "coin6" || x.Name == "coin7" || x.Name == "coin8" || x.Name == "coin9" || x.Name == "coin10")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(pacman.Bounds))
                    {
                        this.Controls.Remove(x);
                        puntaje++;
                    }
                }
                if (x is PictureBox && x.Name == "cherry")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(pacman.Bounds))
                    {
                        this.Controls.Remove(x);
                        timer2.Start();
                        timer3.Stop();
                        puntaje += 10;
                    }
                }
                if (x is PictureBox && x.Name == "pera")
                {
                    if (((PictureBox)x).Bounds.IntersectsWith(pacman.Bounds))
                    {
                        this.Controls.Remove(x);
                        timer2.Start();
                        timer3.Stop();
                        puntaje += 15;
                    }
                }
            }
        }