/// <summary>
 /// metodo que define las variables de conexion con el servidor que va a utilizar
 /// </summary>
 /// <param name="instanceContext">contexto del usuario </param>
 /// <param name="chatClient">conexion a la interfaz de chat y multijugador</param>
 /// <param name="service1Client">conexion a la interfaz de Service1</param>
 public void setServidor(InstanceContext instanceContext, ServiceReference4.ChatClient chatClient,
                         ServiceReference4.Service1Client service1Client)
 {
     contexto = instanceContext;
     servidor = chatClient;
     service  = service1Client;
 }
        /// <summary>
        /// metodo que valida los datos ingresados
        /// </summary>
        /// <returns></returns>
        private int validarDatosJugador()
        {
            if (nombreTF.Text.Length < 1)
            {
                MessageBox.Show("Existe un error en tu nombre, por favor revisalo", "Error");
                return(0);
            }
            ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
            int yaExiste = servicio.VerificarUsuarioExistente(usuarioTF.Text);

            if (yaExiste == 1)
            {
                MessageBox.Show("El usuario ya existe", "Ya existe");
                return(0);
            }
            if (usuarioTF.Text.Length < 3)
            {
                MessageBox.Show("Existe un error en tu usuario, por favor revisalo", "Error");
                return(0);
            }
            if (contraseniaTF.Password.Length < 5)
            {
                MessageBox.Show("Existe un error en tu contraseña, por favor revisalo", "Error");
                return(0);
            }
            if (correoTF.Text.Length < 1 || correoTF.Text.Length > 50)
            {
                MessageBox.Show("Existe un error en tu correo, por favor revisalo", "Error");
                return(0);
            }

            /*validacionCaracteres = validarCadena(nombreTF.Text);
             * if(vali)*/
            return(1);
        }
        /// <summary>
        /// metodo que carga las puntuaciones de la base de datos
        /// </summary>
        private void cargarPuntuaciones()
        {
            ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
            listaPuntuaciones = servicio.getPuntuaciones();
            listaUsuarios     = servicio.getUsuariosPuntuaciones();
            List <String> listaPuntuaciones1 = new List <string>();
            List <String> listaUsuarios1     = new List <string>();

            if (idioma == 0)
            {
                listaPuntuaciones1.Add("Score:");
                listaUsuarios1.Add("User:"******"Puntuacion:");
                listaUsuarios1.Add("Usuario:");
            }
            foreach (String puntuacion in listaPuntuaciones)
            {
                listaPuntuaciones1.Add(puntuacion);
            }
            foreach (String usuario in listaUsuarios)
            {
                listaUsuarios1.Add(usuario);
            }
            puntuacionesLT.ItemsSource = listaPuntuaciones1;
            usuariosLT.ItemsSource     = listaUsuarios1;
        }
 /// <summary>
 /// metodo que manda a la historia con estado 0
 /// </summary>
 private void estado0()
 {
     fondoIMG.Source        = new BitmapImage(new Uri("C:/Users/rockm/Desktop/5to Semestre/Tecnologias/10ma iteracion/ClienteProyecto/ClienteProyecto/Imagenes/explicacion2.png"));
     explicacionIMG.Content = Properties.Resources.labelExplicacion2;
     this.estado            = 1;
     ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
     service.SetCampaniaJugador(idJugador, 1);
 }
        /// <summary>
        /// metodo que obtiene el ID del jugador
        /// </summary>
        /// <param name="idJugador">Id del jugador</param>
        internal void getID(int idJugador)
        {
            this.idJugador = idJugador;
            ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
            int fichaTu = service.getFichaJugador(idJugador);

            pintarFichaJugador(fichaTu);
        }
示例#6
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     string placeName = TextBox1.Text;
     ServiceReference4.Service1Client proxy = new ServiceReference4.Service1Client();
     TextArea1.InnerText = proxy.GetPopulation(placeName);
     String str = "Place Name: " + placeName + "\n" + TextArea1.InnerText;
     Cache.Insert("CacheItem7", str, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
 }
示例#7
0
 /// <summary>
 /// metodo que determina el idioma de la ventana
 /// </summary>
 /// <param name="idioma">idioma del sistema</param>
 internal void setIdioma(int idioma)
 {
     Console.WriteLine("11 " + idJugador);
     ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
     this.idioma = service.getIdiomaJugador(idJugador);
     Console.WriteLine("el idioma es: " + this.idioma);
     if (this.idioma != 0)
     {
         aplicarIdioma();
     }
 }
 private void aceptarBT_Click(object sender, RoutedEventArgs e)
 {
     try {
         igualarContrasenias();
         int validacion = validarDatosJugador();
         if (validacion == 0)
         {
             return;
         }
         ServiceReference4.Jugador jugador = new ServiceReference4.Jugador();
         jugador.contrasenia = ComputeSha256Hash(contraseniaTF.Password);
         jugador.email       = correoTF.Text;
         jugador.estado      = 0;
         if (validarCadena(nombreTF.Text))
         {
             jugador.nombre = nombreTF.Text;
         }
         else
         {
             MessageBox.Show("Error en el nombre");
             return;
         }
         if (validarCadena(usuarioTF.Text))
         {
             jugador.usuario = usuarioTF.Text;
         }
         else
         {
             MessageBox.Show("Error en el Usuario");
             return;
         }
         jugador.campania        = 0;
         jugador.fichaCampania   = 0;
         jugador.idioma          = 0;
         jugador.partidasJugadas = 0;
         jugador.codigo          = generarCodigo();
         int validacionCorreo = 0;
         validacionCorreo = enviarCodigo(jugador.codigo);
         if (validacionCorreo != 0)
         {
             MessageBox.Show("Ocurrio un error al enviar el correo", "Error");
             return;
         }
         ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
         servicio.InsertarJugador(jugador);
         //mandar a la ventana validar
         Validar validar = new Validar();
         validar.setIdioma(idioma);
         validar.Show();
         this.Close();
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
        /// <summary>
        /// metodo que determina los botones disponibles para la seleccion de campaña del jugador
        /// </summary>
        private void determinarBotones()
        {
            ServiceReference4.Service1Client service1Client = new ServiceReference4.Service1Client();
            int progreso = service1Client.GetCampaniaJugador(idJugador);

            Console.WriteLine("Progreso: " + progreso);
            if (progreso == 0)
            {
                Console.WriteLine("quito el continuar");
                continuaBT.IsEnabled = false;
            }
        }
        /// <summary>
        /// metodo que manda a el juego con estado 1
        /// </summary>
        private void estado1()
        {
            ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
            service.SetCampaniaJugador(idJugador, 2);
            JuegoCampaña juego = new JuegoCampaña();

            juego.setIdioma(idioma);
            juego.getID(idJugador);
            juego.ajustarImagenes(2);
            juego.Show();
            this.Close();
        }
示例#11
0
 /// <summary>
 /// metodo que obtiene el id del jugador
 /// </summary>
 /// <param name="idJugador">id del jugador</param>
 /// <param name="estado">estado de campaña</param>
 public void getID(int idJugador, int estado)
 {
     this.idJugador = idJugador;
     if (estado == 0)
     {
         ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
         ficha = service.getFichaJugador(idJugador);
         PintarFicha(ficha);
     }
     else
     {
         PintarFicha(respaldoFicha);
     }
 }
示例#12
0
 private void guardarBT_Click(object sender, RoutedEventArgs e)
 {
     try {
         MenuPrincipal menuPrincipal = new MenuPrincipal();
         ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
         servicio.setOpciones(idJugador, idioma, ficha);
         menuPrincipal.getID(idJugador);
         menuPrincipal.setIdioma(idioma);
         menuPrincipal.Show();
         this.Close();
     } catch (Exception) {
         MessageBox.Show("ocurrio un error inesperado", "error");
     }
 }
 private void Button_Click(object sender, RoutedEventArgs e)  //LLama a la historia nueva
 {
     try {
         ServiceReference4.Service1Client service1Client = new ServiceReference4.Service1Client();
         service1Client.SetCampaniaJugador(idJugador, 1);
         Historia historia = new Historia();
         historia.getID(idJugador);
         historia.setIdioma(idioma);
         historia.setIMG(0);
         historia.Show();
         this.Close();
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
 /// <summary>
 /// metodo que manda a el juego con estado 3
 /// </summary>
 private void estado3()
 {
     try {
         ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
         service.SetCampaniaJugador(idJugador, 5);
         JuegoCampaña juego = new JuegoCampaña();
         juego.setIdioma(idioma);
         juego.getID(idJugador);
         juego.ajustarImagenes(5);
         juego.Show();
         this.Close();
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
 private void Button_Click_1(object sender, RoutedEventArgs e)  //llama continuar
 {
     try {
         int progreso;
         ServiceReference4.Service1Client service1Client = new ServiceReference4.Service1Client();
         progreso = service1Client.GetCampaniaJugador(idJugador);
         JuegoCampaña juego = new JuegoCampaña();
         juego.getID(idJugador);
         juego.setIdioma(idioma);
         juego.ajustarImagenes(progreso);
         juego.Show();
         this.Close();
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
示例#16
0
        private void inicioBT_Click(object sender, RoutedEventArgs e)
        {
            try {
                igualarContrasenias();
                String usuario;
                if (validarCadena(usuarioTB.Text))
                {
                    usuario = usuarioTB.Text;
                }
                else
                {
                    MessageBox.Show("Error en el usuario");
                    return;
                }
                String contrasenia = ComputeSha256Hash(contraseniaTB.Password);
                int    idJugador;
                ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
                idJugador = servicio.login(usuario, contrasenia);
                if (idJugador == 0)
                {
                    MessageBox.Show("tu usuario o contraseña no son validos", "error");
                    return;
                }
                else
                {
                    var estado = servicio.getEstado(idJugador);
                    if (estado == 0)
                    {
                        MessageBox.Show("para ingresar debes validar tu cuenta", "error");
                        return;
                    }
                }

                MenuPrincipal menuPrincipal = new MenuPrincipal();
                menuPrincipal.getID(idJugador);
                menuPrincipal.setIdioma(idioma);

                menuPrincipal.Show();
                this.Close();
            } catch (System.ServiceModel.EndpointNotFoundException) {
                MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
            }
        }
示例#17
0
        public void luz(String dato)
        {
            ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();

            string monto;

            monto = service.FacturaLuz(dato);

            if (monto != " ")
            {
                String[] ArraySabadoI = monto.Split(',');

                montoluz = ArraySabadoI[0];
                fechaluz = ArraySabadoI[1];
            }
            else
            {
                montoluz = "error";
            }
        }
 /// <summary>
 /// metodo que envia el codigo del
 /// </summary>
 /// <param name="codigo"></param>
 private int enviarCodigo(String codigo)
 {
     try {
         String mensaje;
         String asunto;
         if (idioma == 0)
         {
             mensaje = Properties.Resources.StringMensaje;
             asunto  = Properties.Resources.StringAsunto;
         }
         else
         {
             mensaje = Properties.Recursos.StringMensaje;
             asunto  = Properties.Recursos.StringAsunto;
         }
         ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
         return(service.enviarCodigo(codigo, correoTF.Text, asunto, mensaje));
     } catch (Exception) {
         MessageBox.Show("No se pudo mandar el correo");
         return(1);
     }
 }
示例#19
0
 private void crearBT_Click(object sender, RoutedEventArgs e)
 {
     try {
         MiLlamadaDeVuelta            mi       = new MiLlamadaDeVuelta();
         ServiceReference4.ChatClient servidor = new ServiceReference4.ChatClient(new InstanceContext(mi));
         String nombre = nombreTB.Text;
         servidor.crearPartida(nombre);
         ServiceReference4.Service1Client service;
         service = new ServiceReference4.Service1Client();
         String usuarioN;
         usuarioN = service.getUsuarioUsuario(idJugador);
         Console.WriteLine("10 " + usuarioN + " 55 " + nombre);
         Lobby lobby = new Lobby();
         lobby.setIdioma(idioma);
         lobby.setPartida(nombre);
         lobby.getID(idJugador);
         lobby.Show();
         this.Close();
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
示例#20
0
 private void aceptarBT_Click(object sender, RoutedEventArgs e)
 {
     try {
         bool correcto = false;
         var  codigo   = codigoTF.Text;
         ServiceReference4.Service1Client servicio = new ServiceReference4.Service1Client();
         correcto = servicio.validarUsusario(codigo);
         if (correcto == true)
         {
             MessageBox.Show("tu cuenta fue validada con exito", "exito");
             MainWindow mainWindow = new MainWindow();
             mainWindow.setIdioma(idioma);
             mainWindow.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("este codigo no pertenece a ningun usuario\nrevisalo por favor", "error");
         }
     } catch (System.ServiceModel.EndpointNotFoundException) {
         MessageBox.Show("Hubo un error al conectar con el servidor", "Error en el host");
     }
 }
        /// <summary>
        /// metodo que define la interaccion cuando gana el jugador
        /// </summary>
        /// <param name="avance">numero de avance en la campaña del jugador</param>
        private void manejarVictoria(int avance)
        {
            ServiceReference4.Service1Client service1Client = new ServiceReference4.Service1Client();
            switch (avance)
            {
            case 2: {
                service1Client.SetCampaniaJugador(idJugador, 3);
                Historia historia = new Historia();
                historia.getID(idJugador);
                historia.setIdioma(idioma);
                historia.setIMG(3);
                historia.Show();
                this.Close();
            }
            break;

            case 5: {
                service1Client.SetCampaniaJugador(idJugador, 7);
                Historia historia = new Historia();
                historia.getID(idJugador);
                historia.setIdioma(idioma);
                historia.setIMG(7);
                historia.Show();
                this.Close();
            }
            break;

            case 8: {
                service1Client.SetCampaniaJugador(idJugador, 10);
                Historia historia = new Historia();
                historia.getID(idJugador);
                historia.setIdioma(idioma);
                historia.setIMG(10);
                historia.Show();
                this.Close();
            }
            break;

            case 11: {
                service1Client.SetCampaniaJugador(idJugador, 13);
                Historia historia = new Historia();
                historia.getID(idJugador);
                historia.setIdioma(idioma);
                historia.setIMG(13);
                historia.Show();
                this.Close();
            }
            break;

            case 14: {
                service1Client.SetCampaniaJugador(idJugador, 16);
                Historia historia = new Historia();
                historia.getID(idJugador);
                historia.setIdioma(idioma);
                historia.setIMG(16);
                historia.Show();
                this.Close();
            }
            break;

            default: {
                MessageBox.Show("Lo sentimos pero ocurrio un error inesperado y progreso se reinició", "Ocurrio" +
                                "un error");
            }
            break;
            }
        }
 /// <summary>
 /// metodo que reinicia el progreso del jugador a 0
 /// </summary>
 private void estado17()
 {
     ServiceReference4.Service1Client service = new ServiceReference4.Service1Client();
     service.SetCampaniaJugador(idJugador, 0);
 }