public override void PayResultCallBack(string arg) { base.PayResultCallBack(arg); Debug.Log("------------PayResult=" + arg); string str = ""; SFJSONObject sfjson = new SFJSONObject(arg); string type = (string)sfjson.get("result"); string data = (string)sfjson.get("data"); if (APaymentHelper.PayResult.PAY_SUCCESS == type) { str = "pay result = pay success " + data; } else if (APaymentHelper.PayResult.PAY_FAILURE == type) { str = "pay result = pay failure" + data; } else if (APaymentHelper.PayResult.PAY_ORDER_NO == type) { str = "pay result = pay order No" + data; } SDKLogManager.DebugLog(str); }
public override void ExitGameCallBack(string arg) { base.ExitGameCallBack(arg); //TODO Debug.Log("------------ExitResult=" + arg); SFJSONObject sfjson = new SFJSONObject(arg); string type = (string)sfjson.get("result"); string data = (string)sfjson.get("data"); if (APaymentHelper.ExitResult.SDKEXIT == type) { //SDK退出 if (data.Equals("true")) { Application.Quit(); } else if (data.Equals("false")) { Debug.Log("------------ExitResult=" + data); } } else if (APaymentHelper.ExitResult.SDKEXIT_NO_PROVIDE == type) { Debug.Log("------------退出游戏sdk没有退出框:启动游戏自带的退出界面:"); //游戏自带退出界面 CallAndroidFunc("ShowExitGameView"); //Application.Quit(); } }
private SFJSONObject readObject() { SFJSONObject result = new SFJSONObject(); /* Peek to see if this is the empty object. */ int first = nextCleanInternal(); if (first == '}') { return(null); } else if (first != -1) { pos--; } while (true) { Object name = nextValue(); //APaymentHelperDemo.toAndroidLog(tag, "readObject name:" + name); /* * Expect the name/value separator to be either a colon ':', an * equals sign '=', or an arrow "=>". The last two are bogus but we * include them because that's what the original implementation did. */ int separator = nextCleanInternal(); if (separator != ':' && separator != '=') { //throw syntaxError("Expected ':' after " + name); // APaymentHelperDemo.toAndroidLog(tag, "Expected ':' after " + name); return(null); } if (pos < ins.Length && ins.Substring(pos, 1).ToCharArray()[0] == '>') { pos++; } result.put((string)name, nextValue()); switch (nextCleanInternal()) { case '}': return(result); case ';': case ',': continue; default: // APaymentHelperDemo.toAndroidLog(tag, "Unterminated object"); return(null); // throw syntaxError("Unterminated object"); } } }
public override void LoginCallBack(string arg) { base.LoginCallBack(arg); //TODO 登入验证 Debug.Log("------------loginResult=" + arg); string str = ""; SFJSONObject sfjson = new SFJSONObject(arg); string type = (string)sfjson.get("result"); string customParams = (string)sfjson.get("customParams"); if (APaymentHelper.LoginResult.LOGOUT == type) { str = "login result = logout" + customParams; if (onLogoutComplete != null) { onLogoutComplete(true); } } else if (APaymentHelper.LoginResult.LOGIN_SUCCESS == type) { SFJSONObject userinfo = (SFJSONObject)sfjson.get("userinfo"); string oldchanneluserid; currentSDKParmer.TryGetValue("channeluserid", out oldchanneluserid); if (userinfo != null && (string)userinfo.get("channeluserid") != oldchanneluserid) { //long id = long.Parse((string)userinfo.get("id")); //string channelId = (string)userinfo.get("channelid"); //string ChannelUserId = (string)userinfo.get("channeluserid"); //string UserName = (string)userinfo.get("username"); //string Token = (string)userinfo.get("token"); //string ProductCode = (string)userinfo.get("productcode"); currentSDKParmer["id"] = (string)userinfo.get("id"); //易接内部 userid,该值可能为 0,请不要以此参数作为判定。 currentSDKParmer["channelid"] = (string)userinfo.get("channelid"); //易接平台标示的渠道 SDK ID, currentSDKParmer["channeluserid"] = (string)userinfo.get("channeluserid"); //渠道 SDK 标示的用户 ID。 currentSDKParmer["username"] = (string)userinfo.get("username"); //渠道 SDK 的用户名称。 currentSDKParmer["token"] = (string)userinfo.get("token"); //渠道 SDK 登录完成后的 Session ID。特别提醒:部分渠道此参数会包含特殊值如‘+’,空格之类的,如直接使用 URL 参数传输到游戏服务器请求校验,请使用 URLEncoder 编码 currentSDKParmer["productcode"] = (string)userinfo.get("productcode"); //易接平台创建的游戏 ID,appId onLoginComplete(true); //标志登入成功 str = "login result = login success" + customParams; } else { str = "login result = sdk login success , but game loginfailed ~~~~~" + currentSDKParmer["channeluserid"]; } } else if (APaymentHelper.LoginResult.LOGIN_FAILED == type) { str = "login result = login failed" + customParams; } SDKLogManager.DebugLog(str); }
void LoginCheck() { if (isDebug == true) { bLogined = true; return; } string url = createLoginURL(); Debug.Log("LoginCheck url:" + url); if (url == null) { return; } string result = executeHttpGet(url); Debug.Log("LoginCheck result:" + result); if (result == null || !(result == "SUCCESS")) { bLogined = false; } else { bLogined = true; using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) { setRoleData(curActivity.GetRawObject(), "1", "hunter", "30", "1", "1"); SFJSONObject gameinfo = new SFJSONObject(); gameinfo.put("roleId", "1"); //当前登录的玩家角色ID,必须为数字 gameinfo.put("roleName", "猎人"); //当前登录的玩家角色名,不能为空,不能为null gameinfo.put("roleLevel", "100"); //当前登录的玩家角色等级,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneId", "1"); //当前登录的游戏区服ID,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneName", "阿狸一区"); //当前登录的游戏区服名称,不能为空,不能为null gameinfo.put("balance", "0"); //用户游戏币余额,必须为数字,若无,传入0 gameinfo.put("vip", "1"); //当前用户VIP等级,必须为数字,若无,传入1 gameinfo.put("partyName", "无帮派"); //当前角色所属帮派,不能为空,不能为null,若无,传入“无帮派” gameinfo.put("roleCTime", "21322222"); //单位为秒,创建角色的时间 gameinfo.put("roleLevelMTime", "54456556"); //单位为秒,角色等级变化时间,如果没有就传-1 setData(curActivity.GetRawObject(), "createrole", gameinfo.toString()); //创建新角色时调用,必接接口 setData(curActivity.GetRawObject(), "levelup", gameinfo.toString()); //玩家升级角色时调用,必接接口 setData(curActivity.GetRawObject(), "enterServer", gameinfo.toString()); //选择服务器进入时调用,必接接口 setData(curActivity.GetRawObject(), "loginGameRole", gameinfo.toString()); ////这个接口只有接uc的时候才会用到和setRoleData一样的功能,但是两个放在一起不会出现冲突,必接接口 } } } }
void callback2(string result) { Debug.Log("------------callback2=" + result); SFJSONObject sfjson = new SFJSONObject(result); string tag = (string)sfjson.get("tag"); string value = (string)sfjson.get("value"); Debug.Log("tag:" + tag + " value:" + value); if (tag.Equals("success")) { Debug.Log("成功"); } else { Debug.Log("失败"); } }
// 登陆监听函数 void LoginResult(string result) { Debug.Log("------------loginResult=" + result); SFJSONObject sfjson = new SFJSONObject(result); string type = (string)sfjson.get("result"); string customParams = (string)sfjson.get("customParams"); if (APaymentHelper.LoginResult.LOGOUT == type) { str = "login result = logout" + customParams; user = null; if (!isDebug) { bLogined = false; } Invoke("doLogin", 0.2f); } else if (APaymentHelper.LoginResult.LOGIN_SUCCESS == type) { SFJSONObject userinfo = (SFJSONObject)sfjson.get("userinfo"); if (userinfo != null) { long id = long.Parse((string)userinfo.get("id")); string channelId = (string)userinfo.get("channelid"); string ChannelUserId = (string)userinfo.get("channeluserid"); string UserName = (string)userinfo.get("username"); string Token = (string)userinfo.get("token"); string ProductCode = (string)userinfo.get("productcode"); user = new SFOnlineUser(id, channelId, ChannelUserId, UserName, Token, ProductCode); Debug.Log("## id:" + id + " channelId:" + channelId + " ChannelUserId:" + ChannelUserId + " UserName:"******" Token:" + Token + " ProductCode:" + ProductCode); } str = "login result = login success" + customParams; LoginCheck(); } else if (APaymentHelper.LoginResult.LOGIN_FAILED == type) { str = "login result = login failed" + customParams; } }
// 支付监听函数 void PayResult(string result) { Debug.Log("------------PayResult=" + result); SFJSONObject sfjson = new SFJSONObject(result); string type = (string)sfjson.get("result"); string data = (string)sfjson.get("data"); if (APaymentHelper.PayResult.PAY_SUCCESS == type) { str = "pay result = pay success " + data; } else if (APaymentHelper.PayResult.PAY_FAILURE == type) { str = "pay result = pay failure" + data; } else if (APaymentHelper.PayResult.PAY_ORDER_NO == type) { str = "pay result = pay order No" + data; } }
public override void UpdatePlayerInfo(SDKData.RoleData roleData, SDKData.UpdatePlayerInfoType updateType) { using (AndroidJavaObject curActivity = CallAndroidFuncGetResult <AndroidJavaObject>("GetGameMainActivity")) { string updateType_Key = updateType == SDKData.UpdatePlayerInfoType.createRole ? "createrole" : "levelup"; if (updateType == SDKData.UpdatePlayerInfoType.enterGame) { updateType_Key = "enterServer"; setRoleData(curActivity.GetRawObject(), roleData.roleId, roleData.roleName, roleData.roleLevel, roleData.realmId, roleData.realmName); } SFJSONObject gameinfo = new SFJSONObject(); gameinfo.put("roleId", roleData.roleId); //当前登录的玩家角色ID,必须为数字 gameinfo.put("roleName", roleData.roleName); //当前登录的玩家角色名,不能为空,不能为null gameinfo.put("roleLevel", roleData.roleLevel); //当前登录的玩家角色等级,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneId", roleData.realmId); //当前登录的游戏区服ID,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneName", roleData.realmName); //当前登录的游戏区服名称,不能为空,不能为null gameinfo.put("balance", "0"); //用户游戏币余额,必须为数字,若无,传入0 gameinfo.put("vip", "1"); //当前用户VIP等级,必须为数字,若无,传入1 gameinfo.put("partyName", "无帮派"); //当前角色所属帮派,不能为空,不能为null,若无,传入“无帮派” gameinfo.put("roleCTime", roleData.createTime); //单位为秒,创建角色的时间 gameinfo.put("roleLevelMTime", "-1"); //单位为秒,角色等级变化时间,如果没有就传-1 string gameInfoString = gameinfo.toString(); setData(curActivity.GetRawObject(), updateType_Key, gameInfoString);//各种时机调用,必接接口 if (updateType_Key == "enterServer") { //在调用一遍,游戏里enterserver和logingamerole一样 setData(curActivity.GetRawObject(), "loginGameRole", gameInfoString);////这个接口只有接uc的时候才会用到和setRoleData一样的功能,但是两个放在一起不会出现冲突,必接接口 } } }
//ExitResult 退出监听函数 void ExitResult(string result) { Debug.Log("------------ExitResult=" + result); SFJSONObject sfjson = new SFJSONObject(result); string type = (string)sfjson.get("result"); string data = (string)sfjson.get("data"); if (APaymentHelper.ExitResult.SDKEXIT == type) { //SDK退出 if (data.Equals("true")) { Application.Quit(); } else if (data.Equals("false")) { } } else if (APaymentHelper.ExitResult.SDKEXIT_NO_PROVIDE == type) { //游戏自带退出界面 Application.Quit(); } }
void Awake() { goodName = PlayerPrefs.GetString("goodName", ""); money = PlayerPrefs.GetInt("money", 0); string itemCode = PlayerPrefs.GetString("goodid", ""); string remain = PlayerPrefs.GetString("remain", ""); Debug.Log("itemCode=" + itemCode + " remain=" + remain); bLogined = PlayerPrefs.GetInt("login", 0) == 0 ? false : true; keyName = PlayerPrefs.GetString("keyName", ""); if (goodName.Equals("") || money == 0) { desc = ""; paytype = ""; } else { desc = PlayerPrefs.GetString("desc", ""); paytype = PlayerPrefs.GetString("paytype", ""); } if (keyName.Equals("")) { setDataType = ""; } else { setDataType = PlayerPrefs.GetString("setDataType", ""); } PlayerPrefs.DeleteAll(); if (Application.platform == RuntimePlatform.Android) { using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) { setLoginListener(curActivity.GetRawObject(), "Main Camera", "LoginResult"); Debug.Log("Awake setDataType:" + setDataType); if (bLogined == true) { Debug.Log("Alogin result = login success"); str = "login result = login success"; if (paytype.Equals(PAYTYPE_PAY)) { str = "PAYTYPE_PAY"; pay(curActivity.GetRawObject(), "Main Camera", money, goodName, 1, desc, CP_PAY_SYNC_URL, "PayResult"); } else if (paytype.Equals(PAYTYPE_CHARGE)) { str = "PAYTYPE_CHARGE"; charge(curActivity.GetRawObject(), "Main Camera", goodName, money, 1, desc, CP_PAY_SYNC_URL, "PayResult"); } else if (paytype.Equals(PAYTYPE_PAY_EXTEND)) { str = "PAYTYPE_PAY_EXTEND"; payExtend(curActivity.GetRawObject(), "Main Camera", money, goodName, itemCode, remain, 1, desc, CP_PAY_SYNC_URL, "PayResult"); } else if (setDataType.Equals(PAYTYPE_ROLE)) { str = "PAYTYPE_ROLE"; SFJSONObject gameinfo = new SFJSONObject(); gameinfo.put("roleId", "1"); //当前登录的玩家角色ID,必须为数字 gameinfo.put("roleName", "猎人"); //当前登录的玩家角色名,不能为空,不能为null gameinfo.put("roleLevel", "100"); //当前登录的玩家角色等级,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneId", "1"); //当前登录的游戏区服ID,必须为数字,且不能为0,若无,传入1 gameinfo.put("zoneName", "阿狸一区"); //当前登录的游戏区服名称,不能为空,不能为null gameinfo.put("balance", "0"); //用户游戏币余额,必须为数字,若无,传入0 gameinfo.put("vip", "1"); //当前用户VIP等级,必须为数字,若无,传入1 gameinfo.put("partyName", "无帮派"); //当前角色所属帮派,不能为空,不能为null,若无,传入“无帮派” gameinfo.put("roleCTime", "21322222"); //单位为秒,创建角色的时间 gameinfo.put("roleLevelMTime", "54456556"); //单位为秒,角色等级变化时间,如果没有就传-1 setData(curActivity.GetRawObject(), keyName, gameinfo.toString()); //创建新角色时调用,必接接口 } } Debug.Log("user had payed str:" + str); } } } isPause = false; isFocus = false; }