Пример #1
0
        /// <summary>
        /// Devuelve 1 si se ha realizado con exito y 0 si se ha fallado.
        /// </summary>
        /// <param name="puntuacion"></param>
        /// <returns></returns>
        public async Task <int> crearPuntuacionDAL(Puntuacion puntuacion)
        {
            clsConnection       miConexion = new clsConnection();
            int                 resultado  = 0;
            HttpClient          client     = new HttpClient();
            String              body;
            HttpStringContent   mContenido;
            HttpResponseMessage mRespuesta;

            try
            {
                // Serializamos al objeto persona que recibe
                body = JsonConvert.SerializeObject(puntuacion);

                mContenido = new HttpStringContent(body, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");

                Uri uri = new Uri(miConexion.uriBase + "/Puntuacion");

                mRespuesta = await client.PostAsync(uri, mContenido);

                if (mRespuesta.IsSuccessStatusCode)
                {
                    resultado = 1;
                }
            }
            catch (Exception e) { throw e; }
            return(resultado);
        }
Пример #2
0
    void actualizarPuntuaciones()
    {
        listaPuntuaciones = FindObjectOfType <BaseDeDatos>().listaPuntuaciones;
        string texto_posiciones = "";
        string texto_nombres    = "";
        string texto_puntos     = "";

        if (listaPuntuaciones.Count > 0)
        {
            int posicion = 1 + (6 * (pagina - 1));
            int objetivo = posicion + 6;
            for (int i = posicion; i < objetivo; i++)
            {
                if (listaPuntuaciones.Count > i)
                {
                    Puntuacion puntuacion  = listaPuntuaciones[i];
                    string     nombre      = puntuacion.nombre;
                    string     puntos      = puntuacion.puntos.ToString();
                    string     posicionStr = posicion.ToString();
                    texto_posiciones += posicionStr + "\n";
                    texto_nombres    += nombre + "\n";
                    texto_puntos     += puntos + "\n";
                    posicion++;
                }
            }
        }
        else
        {
            texto_posiciones = "\n\nActualmente no hay registros o hay problemas con la base de datos";
        }
        puntuaciones_pos.GetComponent <TextMeshProUGUI>().text    = texto_posiciones;
        puntuaciones_nombre.GetComponent <TextMeshProUGUI>().text = texto_nombres;
        puntuaciones_puntos.GetComponent <TextMeshProUGUI>().text = texto_puntos;
    }
Пример #3
0
 void Start()
 {
     DontDestroyOnLoad(objetoPuntuacion);
     DontDestroyOnLoad(texto);
     Puntuacion.ObjetoPuntuacion();
     NotificationCenter.DefaultCenter().AddObserver(this, "IncrementarPuntos");
 }
Пример #4
0
        }//Fin de obtenerMapas

        /// <summary>
        /// Con este metodo vamos a obtener una lista de Puntuaciones
        /// </summary>
        /// <returns></returns>
        public List <Puntuacion> obtenerPrimerasCincuentaPuntuaciones()
        {
            List <Puntuacion> listadoPuntuacion = new List <Puntuacion>();
            Puntuacion        puntuacion;

            try
            {
                conexion = miConexion.getConnection();
                miComando.CommandText = "Select top (50) IDRanking,NombreUsuario,Valor from SK_Puntuaciones order by Valor desc";
                miComando.Connection  = conexion;
                miLector = miComando.ExecuteReader();

                //Si hay lineas en el Lector
                while (miLector.Read())
                {
                    puntuacion = new Puntuacion();
                    puntuacion.IDPuntuacion  = (Int32)miLector["IDRanking"];
                    puntuacion.NombreUsuario = (String)miLector["NombreUsuario"];
                    puntuacion.Valor         = (Int32)miLector["Valor"];

                    listadoPuntuacion.Add(puntuacion);
                }
            }
            catch (SqlException sql) { throw sql; }

            return(listadoPuntuacion);
        }//Fin de obtenerMapas
Пример #5
0
 private async void Puntuacion_Clicked(object sender, EventArgs e)
 {
     PrincipalMenu.IsVisible = false;
     Puntuacion.IsVisible    = true;
     Puntuacion.Scale        = 0;
     await Puntuacion.ScaleTo(1, 300);
 }
Пример #6
0
 void Start()
 {
     player        = GameObject.FindGameObjectWithTag("Player");
     scriptJugador = player.GetComponent <Jugador>();
     marcador      = GameObject.FindGameObjectWithTag("Marcador").GetComponent <Puntuacion>();
     Invoke("crearMuerto", temporizador[Random.Range(0, temporizador.Length)]);
 }
        public IHttpActionResult PutPuntuacion(int id, Puntuacion puntuacion)
        {
            if (!ModelState.IsValid || !IsValid(puntuacion))
            {
                return(BadRequest(ModelState));
            }

            if (id != puntuacion.Id)
            {
                return(BadRequest());
            }

            db.Entry(puntuacion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PuntuacionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #8
0
 void OnEnable()
 {
     total.text = Puntuacion.getPuntuacion().ToString();
     Puntuacion.resetPuntuacion();
     record.text = EstadoJuego.estadoJuego.puntuacionMaxima.ToString();
     adHolder.Show();
 }
Пример #9
0
        public async Task <Puntuacion> getPuntuacionBL(int id)
        {
            Puntuacion puntuacion = new Puntuacion();
            PuntuacionManejadoraDAL manejadoraDAL = new PuntuacionManejadoraDAL();
            await manejadoraDAL.getPuntuacionDAL(id);

            return(puntuacion);
        }
Пример #10
0
 //Patron Singleton
 public static Puntuacion ObjetoPuntuacion()
 {
     if (objetoPuntuacion == null)
     {
         gameObjetoPuntuacion = new GameObject("Objeto Puntuacion");
         objetoPuntuacion     = gameObjetoPuntuacion.AddComponent <Puntuacion>();
         //Tell unity not to destroy this object when loading a new scene!
     }
     return(objetoPuntuacion);
 }
Пример #11
0
    void OnMouseDown()
    {
        Application.LoadLevel("Juego");
        DestroyObject(Puntuacion.ObjetoPuntuacion());
        GameObject textPuntuacion = GameObject.Find("TextoPuntuacion");
        GameObject puntua         = GameObject.Find("Puntua");

        DestroyObject(textPuntuacion);
        DestroyObject(puntua);
    }
Пример #12
0
        /**
         * Añade las puntuaciones a las dos listas de puntuaciones
         * */
        public void AddPuntuacion(string nombre, int puntuacion, int distancia)
        {
            Puntuacion marca = new Puntuacion();

            marca.nombre     = nombre;
            marca.puntuacion = puntuacion;
            marca.distancia  = distancia;
            puntuacionesPuntos.Add(marca);
            puntuacionesDistancia.Add(marca);
        }
Пример #13
0
        public void crearFicheroDat()
        {
            FileInfo fi = new FileInfo(Application.persistentDataPath + "/" + "datos.dat");

            if (!fi.Exists)
            {
                IFormatter formatter = new BinaryFormatter();

                Stream stream = new FileStream(Application.persistentDataPath + "/" + "datos.dat", FileMode.Create, FileAccess.Write, FileShare.None);


                SaveGameManager salvaData;
                ControlLogico   cl;
                Puntuacion      punt;
                ArrayList       larmas      = new ArrayList();
                ArrayList       lmembresia  = new ArrayList();
                ArrayList       lEscenario  = new ArrayList();
                ArrayList       lpersonajes = new ArrayList();
                string          lenguaje;
                string          navegacion;

                punt = new Puntuacion(0, 0);

                larmas.Add(new Arma("martillo", false));
                larmas.Add(new Arma("hielo", true));
                larmas.Add(new Arma("palogolf", true));
                larmas.Add(new Arma("rayo", false));

                lEscenario.Add(new Escenario("habana", false));
                lEscenario.Add(new Escenario("corner", true));
                lEscenario.Add(new Escenario("estadio", false));
                lEscenario.Add(new Escenario("callejon", false));
                lEscenario.Add(new Escenario("taquillero", false));
                lEscenario.Add(new Escenario("volcan", false));
                lEscenario.Add(new Escenario("jungla", false));

                lpersonajes.Add(new Personaje("cristiano", false));
                lpersonajes.Add(new Personaje("messi", true));

                lenguaje   = "eng";
                navegacion = "main";

                cl = new ControlLogico(punt);
                cl.SetArmas(larmas);
                cl.SetListEscenario(lEscenario);
                cl.SetMembresia(lmembresia);


                salvaData = new SaveGameManager(cl, lpersonajes, lenguaje, navegacion);

                formatter.Serialize(stream, salvaData);

                stream.Close();
            }
        }
        public IHttpActionResult GetPuntuacion(int id)
        {
            Puntuacion puntuacion = db.Puntuacions.Find(id);

            if (puntuacion == null)
            {
                return(NotFound());
            }

            return(Ok(puntuacion));
        }
Пример #15
0
        //
        // GET: /Puntuacion/CreateReto

        public ActionResult CreateReto(int id)
        {
            SessionInitialize();

            Puntuacion punt = new Puntuacion();

            punt.idReto    = id;
            punt.Actividad = new RetoCAD().GetID(id).Titulo;

            SessionClose();
            return(View(punt));
        }
        public IHttpActionResult PostPuntuacion(Puntuacion puntuacion)
        {
            puntuacion.Fecha = DateTime.Now;
            if (!ModelState.IsValid || !IsValid(puntuacion))
            {
                return(BadRequest(ModelState));
            }

            db.Puntuacions.Add(puntuacion);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = puntuacion.Id }, puntuacion));
        }
        public IHttpActionResult DeletePuntuacion(int id)
        {
            Puntuacion puntuacion = db.Puntuacions.Find(id);

            if (puntuacion == null)
            {
                return(NotFound());
            }

            db.Puntuacions.Remove(puntuacion);
            db.SaveChanges();

            return(Ok(puntuacion));
        }
Пример #18
0
 void Awake()
 {
     if (objetoPuntuacion == null)
     {
         objetoPuntuacion = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         if (this != objetoPuntuacion)
         {
             Destroy(this.gameObject);
         }
     }
 }
Пример #19
0
    void Start()
    {
        puntuacion = 0;
        itemsTotales = GameObject.FindGameObjectsWithTag ("Item").Length;
        bola = GameObject.FindGameObjectWithTag ("Bola");
        plataforma = GameObject.FindGameObjectWithTag ("Plataforma");
        textoPuntuacion = GameObject.FindGameObjectWithTag ("TextoPuntuacion").GetComponent<Text>();
        textoGanar = GameObject.FindGameObjectWithTag ("TextoGanar");
        textoPuntuacionTotal = GameObject.Find ("Total").GetComponent<Text> ();

        textoPuntuacion.text = "Puntos: 0/" + itemsTotales.ToString();
        textoPuntuacionTotal.text = "Total: " + puntuacionTotal.ToString ();

        puntuacionComponente = GetComponent<Puntuacion> ();
        puntuacionComponente.cargarPuntuacionMaxima ();
    }
        private Boolean IsValid(Puntuacion puntuacion)
        {
            Boolean valido = false;
            int     number = 0;

            if (Int32.TryParse(puntuacion.Idcliente.ToString(), out number))
            {
                if (Int32.TryParse(puntuacion.iddisco.ToString(), out number))
                {
                    if (Int32.TryParse(puntuacion.Puntuacion1.ToString(), out number) && puntuacion.Puntuacion1 >= 0 && puntuacion.Puntuacion1 <= 10)
                    {
                        valido = true;
                    }
                }
            }
            return(valido);
        }
        private void btnEditar_Click(object sender, RoutedEventArgs e)
        {
            Puntuacion pro = dtgPuntuacion.SelectedItem as Puntuacion;

            if (pro != null)
            {
                HabilitarCajas(true);
                txbEquipoId.Text = pro.Id.ToString();
                txbPuntos.Text   = pro.Puntos;
                cmbEquipo.Text   = pro.Equipo;
                accionPuntuacion = accion.Editar;
                HabilitarBotones(false);
            }
            else
            {
                MessageBox.Show("Seleccione la puntuacion que desea editar", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Question);
            }
        }
Пример #22
0
        public ActionResult CreateGymkana(Puntuacion punt)
        {
            try
            {
                UsuarioCAD   usucad = new UsuarioCAD();
                UsuarioEN    usuen  = usucad.FiltrarUsuarioPorNombre(User.Identity.Name);
                PuntuacionCP puntcp = new PuntuacionCP();
                GymkanaCAD   gymcad = new GymkanaCAD();
                GymkanaEN    gymen  = gymcad.GetID(punt.id);

                puntcp.CrearPuntuacionParaGymkana(gymen.ID, punt.Puntos, usuen.ID);

                return(RedirectToAction("PuntuacionGymkana", new { id = punt.id }));
            }
            catch
            {
                return(View());
            }
        }
Пример #23
0
        public ActionResult CreateReto(Puntuacion punt)
        {
            try
            {
                UsuarioCAD   usucad = new UsuarioCAD();
                UsuarioEN    usuen  = usucad.FiltrarUsuarioPorNombre(User.Identity.Name);
                PuntuacionCP puntcp = new PuntuacionCP();
                RetoCAD      retcad = new RetoCAD();
                RetoEN       reten  = retcad.GetID(punt.id);

                puntcp.CrearPuntuacionParaReto(reten.ID, punt.Puntos, usuen.ID);

                return(RedirectToAction("PuntuacionReto", new { id = punt.id }));
            }
            catch
            {
                return(View());
            }
        }
Пример #24
0
        public ActionResult rate(Puntuacion pun)
        {
            var estado  = true;
            var mensaje = "";

            try
            {
                Usuario us = (Usuario)Session["Usuario"];
                if (us != null)
                {
                    Puntuacion rating      = new Puntuacion();
                    var        puntaciones = contexto.Puntuacion.Where(p => p.idUsuario == pun.idUsuario && p.idUsuarioPuntua == pun.idUsuarioPuntua).ToList().FirstOrDefault();
                    if (puntaciones == null)
                    {
                        mensaje                = "Se puntuo correctamente.";
                        rating.idUsuario       = pun.idUsuario;
                        rating.idUsuarioPuntua = pun.idUsuarioPuntua;
                        rating.valor           = pun.valor;
                        contexto.Puntuacion.Add(rating);
                        contexto.SaveChanges();
                    }
                    else
                    {
                        mensaje           = "Se puntuo correctamente.";
                        puntaciones.valor = pun.valor;
                        contexto.SaveChanges();
                    }
                }
                else
                {
                    estado  = false;
                    mensaje = "Debe iniciar sesion para poder realizar esta accion.";
                }
            }
            catch (Exception e)
            {
                estado  = false;
                mensaje = "Ocurrio un error: " + e.Message.ToString();
            }


            return(Json(new { result = estado, mensaje = mensaje }));
        }
        private void btnEliminar_Click(object sender, RoutedEventArgs e)
        {
            Puntuacion pro = dtgPuntuacion.SelectedItem as Puntuacion;

            if (pro != null)
            {
                if (MessageBox.Show("Realmente deseas eliminar esta puntuacion?", "Puntuacion", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    if (manejadorPuntuacion.Eliminar(pro.Id))
                    {
                        MessageBox.Show("la puntuacion ha sido eliminado correctamente", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Information);
                        ActualizarTabla();
                    }
                    else
                    {
                        MessageBox.Show("la puntuacion no se pudo eliminar", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
Пример #26
0
        /// <summary>
        /// metodo que agrega la puntuacion de una victoria
        /// </summary>
        /// <param name="idJugador"></param>
        /// <param name="turnos"></param>
        /// <returns></returns>
        public int agregarPuntuacionVictoria(int idJugador, int turnos)
        {
            Jugador         jugador1 = new Jugador();
            Model1Container BD       = new Model1Container();
            List <Jugador>  lista    = BD.JugadorSet.ToList();

            foreach (Jugador jugador in lista)
            {
                if (jugador.Id == idJugador)
                {
                    Console.WriteLine("idioma: " + jugador.idioma + " jugador: " + jugador.usuario);
                    jugador1 = jugador;
                }
            }
            Puntuacion puntuacion = new Puntuacion();

            puntuacion.Jugador    = jugador1;
            puntuacion.puntuacion = turnos;
            puntuacion.fecha      = DateTime.Now;
            return(1);
        }
Пример #27
0
        /// <summary>
        /// Este metodo va a insertar un objeto de tipo Puntuacion
        /// </summary>
        public void insertarPuntuacion(int idMapa, int valoracion, Puntuacion puntuacion)
        {
            miComando.Parameters.Add("@NombreUsuario", System.Data.SqlDbType.NVarChar).Value = puntuacion.NombreUsuario;
            miComando.Parameters.Add("@Valor", System.Data.SqlDbType.Int).Value = puntuacion.Valor;

            //Valorar un mapa
            valorarMapa(idMapa, valoracion);

            try
            {
                conexion = miConexion.getConnection();
                //Insertamos los datos de la persona en la base de datos
                miComando.CommandText = "Insert into SK_Puntuaciones (NombreUsuario,Valor)" +
                                        " values(@NombreUsuario,@Valor)";

                miComando.Connection = conexion;

                //ejecutamos el comando de actualizar
                miComando.ExecuteNonQuery();
            }
            catch (SqlException sql) { throw sql; }
        }//insertarPuntuacion
Пример #28
0
        private async void enviarPuntuacion(ContentDialog sender, ContentDialogButtonClickEventArgs e)
        {
            StackPanel sp     = (StackPanel)sender.Content;
            TextBox    edit   = (TextBox)sp.Children[1];
            String     nombre = edit.Text;

            if (String.IsNullOrEmpty(nombre))
            {
                nombre = "Anónimo";
            }

            //Enviar puntación al server
            PuntuacionManejadoraBL puntuacionManejadora = new PuntuacionManejadoraBL();
            Puntuacion             puntuacion           = new Puntuacion(nombre, serpiente.puntuacion);

            if (serpiente.puntuacion > 0)
            {
                await puntuacionManejadora.crearPuntuacionBL(puntuacion);
            }

            reiniciarJuego();
        }
 private void btnGuardar_Click(object sender, RoutedEventArgs e)
 {
     if (accionPuntuacion == accion.Nuevo)
     {
         Puntuacion pro = new Puntuacion()
         {
             Puntos = txbPuntos.Text,
             Equipo = cmbEquipo.Text,
         };
         if (manejadorPuntuacion.Agregar(pro))
         {
             MessageBox.Show("La puntuacion se ha agregado correctamente", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Information);
             ActualizarTabla();
             HabilitarBotones(true);
             HabilitarCajas(false);
         }
         else
         {
             MessageBox.Show("La puntuacion no se pudo agregar", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         Puntuacion pro = dtgPuntuacion.SelectedItem as Puntuacion;
         pro.Puntos = txbPuntos.Text;
         pro.Equipo = cmbEquipo.Text;
         if (manejadorPuntuacion.Modificar(pro))
         {
             MessageBox.Show("Puntuacion modificado correctamente", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Information);
             ActualizarTabla();
             HabilitarBotones(true);
             HabilitarCajas(false);
         }
         else
         {
             MessageBox.Show("La puntuacion no se pudo actualizar", "Puntuacion", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
Пример #30
0
    void Start()
    {
        // Conectamos con la base de datos
        try
        {
            db = FirebaseFirestore.GetInstance(FirebaseApp.Create()); // Se cierra también :/
        }
        catch
        {
            db = FirebaseFirestore.GetInstance(FirebaseApp.DefaultInstance); //<- Bug!
        }

        // Creamos una referencia a una colección (es decir, a una """tabla""" para luego trabajar con los datos)
        CollectionReference puntuaciones = db.Collection("puntuaciones");

        // Preparamos la Query
        Query query = puntuaciones.OrderByDescending("puntos").Limit(30);

        // Creamos un listener con la Query, es decir, recogemos los datos pero no solo eso
        // sino que también, este listener se ejecutará cada vez que haya un cambio en la BBDD
        ListenerRegistration listener = query.Listen(snapshot =>
        {
            List <Puntuacion> cargandoPuntuaciones = new List <Puntuacion>();
            //Guardo continuamente los jugadores en una lista para enseñarla cuando muestre la tabla de puntuaciones
            foreach (DocumentSnapshot documentSnapshot in snapshot.Documents)
            {
                Dictionary <string, object> punt = documentSnapshot.ToDictionary();
                Puntuacion puntuacion            = new Puntuacion();
                puntuacion.nombre = $"{punt["nombre"]}";
                string puntosStr  = $"{punt["puntos"]}";
                puntuacion.puntos = int.Parse(puntosStr);
                cargandoPuntuaciones.Add(puntuacion);
            }
            listaPuntuaciones = cargandoPuntuaciones;
        });
    }
Пример #31
0
 private void aumentarVelocidadConPuntuacion()
 {
     this.velocidad += (float)0.001 * Puntuacion.getPuntuacion();
 }