private void mostrarCartaContrincante(int nCarta) //Muestra la carta de nuestro contrincante { if (anfitrionPartida == hostEnApp) //Si nosotros somos los anfitriones, la carta que llega, sí o sí es del rival { picCard2.ImageLocation = Directorio + "/Cartas/card" + nCarta + ".PNG"; timer2.Enabled = true; cartasPartida[1] = new Cartas(); cartasPartida[1] = cartas[nCarta - 1]; vidaContrincante1.Text = "Vida: " + cartasPartida[1].GetHp(); } else { picCard1.ImageLocation = Directorio + "/Cartas/card" + nCarta + ".PNG"; timer1.Enabled = true; cartasPartida[0] = new Cartas(); cartasPartida[0] = cartas[nCarta - 1]; vidaAnfitrion.Text = "Vida: " + cartasPartida[0].GetHp(); } permisoParaAtacar = true; }
private void PickCard_Click(object sender, EventArgs e) //Escoger las cartas del jugador de forma aleatoria y de 1 en 1 { int mazo1, mazo2, mazo3, mazo4; mazo1 = random.Next(1, 9); mazo2 = random.Next(1, 9); mazo2 = random.Next(1, 9); mazo2 = random.Next(1, 9); mazo3 = random.Next(1, 9); mazo3 = random.Next(1, 9); mazo4 = random.Next(1, 9); if (!permisoParaCoger) { chatPartida.Items.Add("No puedes coger más cartas, tu carta actual aún está viva."); } else { if (permisoParaCoger && cantidadJugadores == 2 && anfitrionPartida == hostEnApp) { switch (mazo1) { case 1: picCard1.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard1.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard1.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard1.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard1.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard1.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard1.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard1.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "30/" + this.nForm + "/" + mazo1; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo1; cartas_picture_vector[1] = picCard1; picCard1.Tag = mazo1 - 1; picCard1.Click += new System.EventHandler(this.eventoClick); timer1.Enabled = true; cartasPartida[0] = new Cartas(); cartasPartida[0] = cartas[mazo1 - 1]; vidaAnfitrion.Text = "Vida: " + cartasPartida[0].GetHp(); } else if (permisoParaCoger && cantidadJugadores == 2 && anfitrionPartida != hostEnApp) { switch (mazo2) { case 1: picCard2.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard2.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard2.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard2.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard2.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard2.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard2.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard2.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "30/" + this.nForm + "/" + mazo2; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo2; cartas_picture_vector[1] = picCard2; picCard2.Tag = mazo2 - 1; picCard2.Click += new System.EventHandler(this.eventoClick); timer2.Enabled = true; cartasPartida[1] = new Cartas(); cartasPartida[1] = cartas[mazo2 - 1]; vidaContrincante1.Text = "Vida: " + cartasPartida[1].GetHp(); } if (permisoParaCoger && cantidadJugadores == 4) { if (hostEnApp == anfitrionPartida) { switch (mazo1) { case 1: picCard1.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard1.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard1.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard1.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard1.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard1.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard1.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard1.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "31/" + this.nForm + "/" + mazo1 + "/" + hostEnApp; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo1; cartas_picture_vector[1] = picCard1; picCard1.Tag = mazo1 - 1; picCard1.Click += new System.EventHandler(this.eventoClick); timer3.Enabled = true; } if (hostEnApp == Player2) { switch (mazo2) { case 1: picCard2.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard2.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard2.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard2.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard2.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard2.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard2.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard2.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "31/" + this.nForm + "/" + mazo2 + "/" + hostEnApp; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo2; cartas_picture_vector[1] = picCard2; picCard2.Tag = mazo2 - 1; picCard2.Click += new System.EventHandler(this.eventoClick); timer4.Enabled = true; } if (hostEnApp == Player3) { switch (mazo3) { case 1: picCard3.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard3.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard3.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard3.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard3.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard3.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard3.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard3.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "31/" + this.nForm + "/" + mazo3 + "/" + hostEnApp; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo3; cartas_picture_vector[1] = picCard3; picCard3.Tag = mazo3 - 1; picCard3.Click += new System.EventHandler(this.eventoClick); timer5.Enabled = true; } if (hostEnApp == Player4) { switch (mazo4) { case 1: picCard4.ImageLocation = Directorio + "/Cartas/card1.PNG"; break; case 2: picCard4.ImageLocation = Directorio + "/Cartas/card2.PNG"; break; case 3: picCard4.ImageLocation = Directorio + "/Cartas/card3.PNG"; break; case 4: picCard4.ImageLocation = Directorio + "/Cartas/card4.PNG"; break; case 5: picCard4.ImageLocation = Directorio + "/Cartas/card5.PNG"; break; case 6: picCard4.ImageLocation = Directorio + "/Cartas/card6.PNG"; break; case 7: picCard4.ImageLocation = Directorio + "/Cartas/card7.PNG"; break; case 8: picCard4.ImageLocation = Directorio + "/Cartas/card8.PNG"; break; } permisoParaCoger = false; cont++; string mensaje = "31/" + this.nForm + "/" + mazo4 + "/" + hostEnApp; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); cartaEscogida1 = mazo4; cartas_picture_vector[1] = picCard4; picCard4.Tag = mazo4 - 1; picCard4.Click += new System.EventHandler(this.eventoClick); timer6.Enabled = true; } } } }