public static void syncWithServer(Action <string> onSuccess, Action <string> onFail) { Dictionary <string, string> data = new Dictionary <string, string> (); data.Add("game_id", "bunnypop"); data.Add("device_id", SystemInfo.deviceUniqueIdentifier); YApi.POST("http://ads.haanhmedia.com/city_run/getData.php", data, (result) => { try{ Player player = JsonMapper.ToObject <Player>(result); player.save(); InitScriptName.InitScript.Gems = player.gems; InitScriptName.InitScript.Lifes = player.life; if (onSuccess != null) { onSuccess(""); } }catch (Exception ex) { Debug.Log(ex.Message); if (onFail != null) { onFail(""); } } }, onFail); }
public static void saveToServer(Action <string> onSuccess, Action <string> onFail) { Player player = Player.makePlayer(); string jsonString = JsonMapper.ToJson(player); Dictionary <string, string> data = new Dictionary <string, string> (); data.Add("game_id", "bunnypop"); data.Add("device_id", SystemInfo.deviceUniqueIdentifier); data.Add("dataSave", jsonString); YApi.POST("http://ads.haanhmedia.com/city_run/saveData.php", data, onSuccess, onFail); }
public static void POST(string url, Dictionary <string, string> data = null, Action <string> onSuccess = null, Action <string> onFail = null, float timeOut = 10, Action <string> onTimeOut = null) { YApi yApi = FindObjectOfType <YApi> (); if (yApi == null) { GameObject obj = new GameObject("YApi"); yApi = obj.AddComponent <YApi> (); } yApi.post(url, data, onSuccess, onFail); }
public static void GET_SPRITE(string url, Action <Sprite> callBack) { YApi yApi = FindObjectOfType <YApi> (); yApi.StartCoroutine(yApi.downloadPicture(url, callBack)); }