Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using GooglePlayGames;
- using UnityEngine.SocialPlatforms;
- public class SalvarWeb : MonoBehaviour {
- //public TextMesh User;
- public string url = "http://xtremelevel.net/Alka/ES2.php";
- public string username;
- public static string filename = "";
- public string webUsername = "ES2";
- public string webPassword = "65w84e4p994z3Oq";
- //public string UserName;
- public int[] intArray;
- public int[] Check;
- private string VariableGuardar;
- // Use this for initialization
- void Awake () {
- #if UNITY_ANDROID
- filename = Social.localUser.userName + ".txt";
- #endif
- //UserName = "Usuario"; // UserName
- //filename = UserName + ".txt";
- //UserID = Social.localUser.id; // UserID
- //ProfilePic =Social.localUser.image; // ProfilePic
- }
- public void Descargar(){
- StartCoroutine ("Download", "Datos");
- }
- public void Subir(){
- StartCoroutine ("Upload", "Datos");
- }
- public IEnumerator Upload(string tag)
- {
- username = Social.localUser.userName;
- filename = username + ".txt";
- string myURL = "http://xtremelevel.net/Alka/ES2.php?";
- myURL += "webfilename=" + filename + "&webusername="+webUsername + "&webpassword=" +webPassword;
- Debug.Log (myURL + "&tag=" + tag);
- ES2Web web = new ES2Web(myURL + "&tag=" + tag);
- intArray [0] = Estadodejuego.estadojuego.puntacionMaxima;
- intArray [1] = Estadodejuego.estadojuego.puntacionMaxima1;
- intArray [2] = Estadodejuego.estadojuego.puntacionMaxima2;
- intArray [3] = Estadodejuego.estadojuego.puntacionMaxima3;
- intArray [4] = Estadodejuego.estadojuego.puntacionMaxima4;
- // Start uploading our data and wait for it to finish.
- yield return StartCoroutine(web.UploadRaw(intArray));
- if(web.isError)
- {
- // Enter your own code to handle errors here.
- // For a list of error codes, see the ES2Web Error Codes Page.
- Debug.LogError(web.errorCode + ":" + web.error);
- }
- }
- public IEnumerator Download(string tag)
- {
- yield return new WaitForSeconds (2);
- username = Social.localUser.userName;
- filename = username + ".txt";
- string myURL = "http://xtremelevel.net/Alka/ES2.php?";
- myURL += "webfilename=" + filename + "&webusername="+webUsername + "&webpassword=" +webPassword;
- Debug.Log (myURL + "&tag=" + tag);
- ES2Web web = new ES2Web(myURL + "&tag=" + tag);
- // Start uploading our data and wait for it to finish.
- yield return StartCoroutine(web.Download());
- if(web.isError)
- {
- // Enter your own code to handle errors here.
- // For a list of error codes, see the ES2Web Error Codes Page.
- Debug.LogError(web.errorCode + ":" + web.error);
- }
- // Now save our data to file so we can use ES2.Load to load it later.
- web.SaveToFile (filename);
- Check = ES2.LoadArray<int> ( filename +"?tag=Datos");
- Estadodejuego.estadojuego.puntacionMaxima = Check [0];
- Estadodejuego.estadojuego.puntacionMaxima1 = Check [1];
- Estadodejuego.estadojuego.puntacionMaxima2 = Check [2];
- Estadodejuego.estadojuego.puntacionMaxima3 = Check [3];
- Estadodejuego.estadojuego.puntacionMaxima4 = Check [4];
- }
- // Update is called once per frame
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement