public IEnumerator PostAgregarPuntaje(string url, PostPuntaje postPuntaje) { //recojo datos del tutor y del juego para guardar a la bdd var jsonData = JsonUtility.ToJson(postPuntaje); using (UnityWebRequest www = UnityWebRequest.Post(url, jsonData)) { www.SetRequestHeader("content-type", "application/json"); www.uploadHandler.contentType = "application/json"; www.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonData)); yield return(www.SendWebRequest()); if (www.isNetworkError) { Debug.Log(www.error); } else { if (www.isDone) { // handle the result var result = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data); var msg = JsonUtility.FromJson <Msg>(result); Debug.Log(msg.msg); } else { //handle the problem Debug.Log("Error! data couldn't get."); } } } }
public void btnbnext() { if (cont == 10) { source.clip = gana; } if (cont >= 10) { if (sc2 != null) { sc2.estado = "COMPLETADO"; sc2.nivel = cont; sc2.score = intentos; Debug.Log(sc2.estudianteId._id); Debug.Log(sc2.juegoId._id); PostPuntaje postPuntaje = new PostPuntaje() { score = sc2.score, estado = sc2.estado, nivel = sc2.nivel, fecha = sc2.fecha, estudianteId = sc2.estudianteId._id, juegoId = sc2.juegoId._id }; //db.Updatescore("etiquetar",sc); StartCoroutine(PostActualizarPuntaje(postPuntajeEditUrl, postPuntaje, sc2._id)); } else { sc = new score(0, "" + intentos, "" + DateTime.Now, "completado", cont); PostPuntaje postPuntaje = new PostPuntaje() { score = intentos, nivel = 10, fecha = DateTime.Now.ToString(), estado = "completado", estudianteId = LoginE.getlog()._id, juegoId = idjuego }; //db.GuardarScore(sc, "etiquetar"); StartCoroutine(PostAgregarPuntaje(postJuegoCreateUrl, postPuntaje)); } SceneManager.LoadScene("Principal"); } else { Reload(); } }
public void MostrarMenuGanador() { if (cont >= 10) { if (sc2 != null) { sc2.estado = "COMPLETADO"; sc2.nivel = aux; sc2.score = intentos; //db.Updatescore("Laterabilidad", sc); Debug.Log(sc2.estudianteId._id); Debug.Log(sc2.juegoId._id); PostPuntaje postPuntaje = new PostPuntaje() { score = sc2.score, estado = sc2.estado, nivel = sc2.nivel, fecha = sc2.fecha, estudianteId = sc2.estudianteId._id, juegoId = sc2.juegoId._id }; StartCoroutine(PostActualizarPuntaje(postPuntajeEditUrl, postPuntaje, sc2._id)); } else { sc = new score(0, "" + intentos, "" + DateTime.Now, "completado", cont); PostPuntaje postPuntaje = new PostPuntaje() { score = intentos, nivel = 1, fecha = DateTime.Now.ToString(), estado = "completado", estudianteId = LoginE.getlog()._id, juegoId = idjuego }; StartCoroutine(PostAgregarPuntaje(postJuegoCreateUrl, postPuntaje)); // db.GuardarScore(sc, "Laterabilidad"); } SceneManager.LoadScene("Principal"); } menuGanador.SetActive(true); menuMostradoGanador = true; textoMenuGanador.text = "HAS GANADO!" + '\n' + "Has encontrado todas las parejas en " + '\n' + tiempo; segundosTot += SegundosCronometro; }
// Start is called before the first frame update void Start() { //StartCoroutine(GetListarPuntaje(geturl)); PostPuntaje postPuntaje = new PostPuntaje() { score = 10, nivel = 2, fecha = "02/03/1997", estado = "COMPLETO", juegoId = "5f1d04b27720803f443031bd", estudianteId = "5f127532929dcd1e14a8e039" }; StartCoroutine(PostAgregarPuntaje(posturl, postPuntaje)); // StartCoroutine(GetPuntajeById(getbyId, "")); }