示例#1
0
        private void Connection1()
        {
            while (true)
            {
                if (cliente[1].Available > 0)
                {
                    try
                    {
                        Jugada j1 = j1 = (Jugada)Recibir_Objeto(cliente[1]);
                        if (j1 != null)
                        {
                            //j1.atacoAntes = p.matrizJuego[j1.posX, j1.posY].atacado;
                            jugadasUno.Add(j1);
                            Server.Enviar(cliente[1], p.revisarJugada2(j1));
                            int j = p.matrizJuego[j1.posX, j1.posY].dueño;
                            if (p.matrizJuego[j1.posX, j1.posY].atacado < 0)
                            {
                                p.matrizJuego[j1.posX, j1.posY].atacado = j1.dueño + 10;
                            }

                            listas.ElementAt(j - 1).Add(j1); // prueba
                            jugadasUno.Remove(jugadasUno.ElementAt(0));
                        }
                    }
                    catch { }
                }
                recibirBarcoMuerto1();
            }
        }
        public void dpsDeRevisarJugada3()
        {
            barcosMuertos = barcosMs();
            lock (barcosMuertos)
            {
                if (barcosMuertos.Count > 0)
                {
                    for (int i = 0; i < barcosMuertos.Count; i++)
                    {
                        Barco auxiliar = barcosMuertos.ElementAt(0);
                        Server.Enviar(Server.ClienteQueReciveRespuesta[1], auxiliar);
                        Server.Enviar(Server.ClienteQueReciveRespuesta[2], auxiliar);
                        Server.Enviar(Server.ClienteQueReciveRespuesta[3], auxiliar);
                        barquito(auxiliar);
                        barcosMuertos.Remove(barcosMuertos.ElementAt(0));
                    }
                }
            }
            int ganador = revisarGanador();

            if (ganador != 0)
            {
                Server.Enviar(Server.ClienteQueReciveRespuesta[1], ganador);
                Server.Enviar(Server.ClienteQueReciveRespuesta[2], ganador);
                Server.Enviar(Server.ClienteQueReciveRespuesta[3], ganador);
                hayGanador(ganador);
            }
        }
示例#3
0
 private void ConnectionParaRespuesta3()
 {
     while (true)
     {
         if (listas.ElementAt(0).Count > 0)
         {
             Jugada j1 = listas.ElementAt(0).ElementAt(0);
             j1.atacoAntes = p.matrizJuego[j1.posX, j1.posY].atacado;
             p.juge(j1);
             listas.ElementAt(0).Remove(listas.ElementAt(0).ElementAt(0));
         }
         if (listas.ElementAt(1).Count > 0)
         {
             Jugada j1 = listas.ElementAt(1).ElementAt(0);
             Server.Enviar(ClienteQueReciveRespuesta[1], j1);
             listas.ElementAt(1).Remove(listas.ElementAt(1).ElementAt(0));
         }
         if (listas.ElementAt(2).Count > 0)
         {
             Jugada j1 = listas.ElementAt(2).ElementAt(0);
             Server.Enviar(ClienteQueReciveRespuesta[2], j1);
             listas.ElementAt(2).Remove(listas.ElementAt(2).ElementAt(0));
         }
         if (listas.ElementAt(3).Count > 0)
         {
             Jugada j1 = listas.ElementAt(3).ElementAt(0);
             Server.Enviar(ClienteQueReciveRespuesta[3], j1);
             listas.ElementAt(3).Remove(listas.ElementAt(3).ElementAt(0));
         }
         p.dpsDeRevisarJugada3();
     }
 }