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); }