/// <summary> /// 上传玩家信息到sdk服务器 参数1:玩家参数 参数2:上传时机 /// </summary> public void UpdatePlayerInfo(SDKData.RoleData roleData, UpdatePlayerInfoType updateType = UpdatePlayerInfoType.createRole) { long roleCTime; if (!long.TryParse(roleData.createTime, out roleCTime)) { roleCTime = 0; } var roleModel = new YaoLingSDKCallBackManager.SaveRoleDataModel() { userName = SDK_UserName, roleLevel = long.Parse(roleData.roleLevel), roleCTime = roleCTime, roleId = roleData.roleId, roleName = roleData.roleName, zoneId = roleData.realmId, zoneName = roleData.realmName, }; #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK #if UNITY_ANDROID YaoLingSDKCallBackManager.Instance.CallAndroidFunc(YaoLingSDKCallBackManager.YaoLinAndroidSDKNameType.StartSDKSaveRoleInfo, LitJson.JsonMapper.ToJson(roleModel)); #elif UNITY_IOS SDKIOSFunction.sdkmanagersavedata(roleModel.roleId, roleModel.roleName, roleModel.zoneId, roleModel.roleLevel.ToString(), roleModel.zoneName); #endif #endregion }
/// <summary> /// 保存角色信息(每次登陆进入游戏后,角色信息变化(等级,名字等)时调用) /// </summary> public void SavePlayerInfo(SDKData.RoleData roleData) { #if UNITY_EDITOR #elif UNITY_ANDROID AndroidPlatSDKManager.Instance.SavePlayerInfo(roleData); #elif UNITY_IPHONE #endif }
/// <summary> /// 上传玩家信息到sdk服务器 参数1:玩家参数 参数2:上传时机 /// </summary> public virtual void UpdatePlayerInfo(SDKData.RoleData roleData, SDKData.UpdatePlayerInfoType updateType) { //注:GameRoleInfo的字段,如果游戏有的参数必须传,没有则不用传 GameRoleInfo gameRoleInfo = new GameRoleInfo(); gameRoleInfo.gameRoleBalance = "0"; gameRoleInfo.gameRoleID = roleData.roleId; gameRoleInfo.gameRoleLevel = roleData.roleLevel; gameRoleInfo.gameRoleName = roleData.roleName; gameRoleInfo.partyName = "同济会"; gameRoleInfo.serverID = roleData.realmId; gameRoleInfo.serverName = roleData.realmName; gameRoleInfo.vipLevel = "1"; gameRoleInfo.roleCreateTime = roleData.createTime; //UC与1881渠道必传,值为10位数时间戳 gameRoleInfo.gameRoleGender = "男"; //360渠道参数 gameRoleInfo.gameRolePower = "38"; //360渠道参数,设置角色战力,必须为整型字符串 gameRoleInfo.partyId = "1100"; //360渠道参数,设置帮派id,必须为整型字符串 gameRoleInfo.professionId = "11"; //360渠道参数,设置角色职业id,必须为整型字符串 gameRoleInfo.profession = "法师"; //360渠道参数,设置角色职业名称 gameRoleInfo.partyRoleId = "1"; //360渠道参数,设置角色在帮派中的id gameRoleInfo.partyRoleName = "帮主"; //360渠道参数,设置角色在帮派中的名称 gameRoleInfo.friendlist = "无"; //360渠道参数,设置好友关系列表,格式请参考:http://open.quicksdk.net/help/detail/aid/190 if (updateType == SDKData.UpdatePlayerInfoType.createRole) { QuickSDK.getInstance().createRole(gameRoleInfo);//创建角色 } else if (updateType == SDKData.UpdatePlayerInfoType.enterGame) { QuickSDK.getInstance().enterGame(gameRoleInfo);//开始游戏 } else { QuickSDK.getInstance().updateRole(gameRoleInfo); } showLog("UpdatePlayerInfo", ": " + updateType); }
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一样的功能,但是两个放在一起不会出现冲突,必接接口 } } }
// Use this for initialization void Start() { InitButton = transform.Find("InitButton").GetComponent <Button>(); LoginButton = transform.Find("LoginButton").GetComponent <Button>(); PayOrderButton = transform.Find("PayOrderButton").GetComponent <Button>(); SaveRoleButton = transform.Find("SaveRoleButton").GetComponent <Button>(); LogoutButton = transform.Find("LogoutButton").GetComponent <Button>(); OnGameExitButton = transform.Find("OnGameExitButton").GetComponent <Button>(); SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>(); SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>(); SaveUMengLevelButton.gameObject.SetActive(false); SaveUMengCountButton.gameObject.SetActive(false); SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Init(); U3DTypeSDK.Instance.InitSDK(() => { SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning); InitButton.gameObject.SetActive(false); LoginButton.gameObject.SetActive(true); }, (state) => { if (state) { SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(true); SetGameGoState(false); } else { SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError); } }); }); LoginButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning); // SDKManager.Instance.Login((a) => { }); U3DTypeSDK.Instance.Login(() => { SDKLogManager.DebugLog("登入成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); }); }); PayOrderButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在支付订单!!", SDKLogManager.DebugType.LogWarning); var payOrderData = new SDKData.PayOrderData() { orderId = SDKData.PayOrderData.GetCurrentTimeMiss(), userid = U3DTypeSDK.Instance.Game_UserId, amount = 6, productId = "10001", productName = "钻石", productDesc = "钻石", callbackMessage = "回调给服务器时的附加消息", productCount = 1, callbackUrl = "http://112.345.678.1/payresult.php", roleID = "roleiid", roleName = "roleiid", //角色名字 zoneID = 1, //区id zoneName = "1区", //区名字 orderTime = SDKData.PayOrderData.GetCurrentTimeMiss(), extra = "附加参数不得为空", gamename = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"), }; U3DTypeSDK.Instance.PayItem(payOrderData); // SDKManager.Instance.PayOrder(payOrderData); }); SaveRoleButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在保存角色信息!!", SDKLogManager.DebugType.LogWarning); var roleData = new SDKData.RoleData() { roleId = "123456", roleLevel = "22", roleName = "测试角色", createTime = System.DateTime.Now.Millisecond.ToString(), realmId = "1", realmName = "1区测试服", chapter = "1-1", arg = "这是一条保存角色信息的附加信息!", }; // SDKManager.Instance.SavePlayerInfo(roleData); U3DTypeSDK.Instance.UpdatePlayerInfo(roleData, SDKData.UpdatePlayerInfoType.levelUp); }); LogoutButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登出账号!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Logout(); U3DTypeSDK.Instance.Logout(); }); OnGameExitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.OnGameExit(() => //{ // Debug.LogWarning("SDK 已经退出!"); //}); U3DTypeSDK.Instance.ExitGame(); #if UNITY_EDITOR SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.gameObject.SetActive(true); #endif }); SaveUMengLevelButton.onClick.AddListener(() => { UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestEventID); }); SaveUMengCountButton.onClick.AddListener(() => { var data = new System.Collections.Generic.Dictionary <string, string>() { { "test1", "1" }, { "test2", "4" }, { "test3", "8" }, { "test4", "16" }, }; UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestComputingEvent, data); }); }
/// <summary> /// 上传玩家信息到sdk服务器 参数1:玩家参数 参数2:上传时机 /// </summary> public void UpdatePlayerInfo(SDKData.RoleData roleData, UpdatePlayerInfoType updateType) { if (UpdatePlayerInfoType.levelUp == updateType) { Umeng.GA.SetUserLevel(int.Parse(roleData.roleLevel));//统计玩家等级 } else if (UpdatePlayerInfoType.enterGame == updateType) { Umeng.Analytics.Event("RoleLoginCount");//统计登陆次数 } else if (UpdatePlayerInfoType.createRole == updateType) { } #if YaoLing #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK Debug.LogWarning("调用曜灵116sdk 保存信息!"); long roleCTime; if (!long.TryParse(roleData.createTime, out roleCTime)) { roleCTime = 0; } var roleModel = new YaoLingSDKCallBackManager.SaveRoleDataModel() { userName = UserName, roleLevel = long.Parse(roleData.roleLevel), roleCTime = roleCTime, roleId = roleData.roleId, roleName = roleData.roleName, zoneId = roleData.realmId, zoneName = roleData.realmName, }; YaoLingSDKCallBackManager.Instance.CallAndroidFunc(YaoLingSDKCallBackManager.YaoLinAndroidSDKNameType.StartSDKSaveRoleInfo, LitJson.JsonMapper.ToJson(roleModel)); #endregion #else //TODO 解决时间戳过大传入java中转换成整形失败的问题 if (roleData.createTime.Length >= 10) { long createTime = long.Parse(roleData.createTime); int intTime = (int)(createTime / 10); roleData.createTime = intTime.ToString(); } //设置所有的数据 U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.USER_ID, "userid"); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.USER_NAME, "username"); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_ID, roleData.roleId); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_NAME, roleData.roleName); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_LEVEL, roleData.roleLevel); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ZONE_ID, roleData.realmId); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ZONE_NAME, roleData.realmName); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.SERVER_ID, roleData.realmId); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.SERVER_NAME, roleData.realmName); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.USER_TOKEN, Token); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.USER_HEAD_ID, ""); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.USER_HEAD_URL, ""); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.VIP_LEVEL, "0"); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.PARTY_NAME, ""); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_CREATE_TIME, roleData.createTime); U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_LEVELUP_TIME, "0"); //角色升级时间(单位/秒) U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.ROLE_TYPE, updateType.ToString()); //角色统计信息类型即调用时机,(createRole:创建角色,levelUp:角色升级,enterGame:选定角色进入游戏,不能为空字符串) U3DTypeSDK.Instance.GetUserData().SetData(U3DTypeAttName.SAVED_BALANCE, "0"); U3DTypeBaseData cacheUser = GetUserData(); Debug.Log("send player info : " + cacheUser.DataToString()); bonjour.SetPlayerInfo(cacheUser); #endif }
/// <summary> /// 上传玩家信息到sdk服务器 参数1:玩家参数 参数2:上传时机 /// </summary> public virtual void UpdatePlayerInfo(SDKData.RoleData roleData, SDKData.UpdatePlayerInfoType updateType) { SDKLogManager.DebugLog("Begin UpdatePlayerInfo"); }
// Use this for initialization void Start() { InitButton = transform.Find("InitButton").GetComponent <Button>(); LoginButton = transform.Find("LoginButton").GetComponent <Button>(); PayOrderButton = transform.Find("PayOrderButton").GetComponent <Button>(); SaveRoleButton = transform.Find("SaveRoleButton").GetComponent <Button>(); SaveRoleButton2 = transform.Find("SaveRoleButton2").GetComponent <Button>(); SaveRoleButton3 = transform.Find("SaveRoleButton3").GetComponent <Button>(); LogoutButton = transform.Find("LogoutButton").GetComponent <Button>(); OnGameExitButton = transform.Find("OnGameExitButton").GetComponent <Button>(); SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>(); SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>(); CheckSimulatorButton = transform.Find("CheckSimulatorButton").GetComponent <Button>(); Message = transform.Find("Message").GetComponent <Text>(); SaveUMengLevelButton.gameObject.SetActive(false); SaveUMengCountButton.gameObject.SetActive(false); SetGameGoState(false); LoginButton.gameObject.SetActive(false); sdkmanager = AloneSdk.AloneSDKManager.instance; if (sdkmanager == null) { Debug.LogError("sdkmanager is null !"); return; } InitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning); SDKData.InitArgModel initArg = new SDKData.InitArgModel() { onComplete = (result) => { if (result) { SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning); InitButton.gameObject.SetActive(false); LoginButton.gameObject.SetActive(true); } }, onSDKLogoutComplete = (state) => { if (state) { SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(true); SetGameGoState(false); } else { SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError); } }, onSDKMessageCallBack = (message) => { Message.text = message; }, }; sdkmanager.InitSDK(initArg); }); LoginButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning); // SDKManager.Instance.Login((a) => { }); sdkmanager.Login((result) => { if (result) { SDKLogManager.DebugLog("登入成功!开始验证:", SDKLogManager.DebugType.LogWarning); if (isLoginVerification) { StartCoroutine(LoginVerification((userid) => { SDKLogManager.DebugLog("验证成功,用户id:" + userid, SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); })); } else { SDKLogManager.DebugLog("验证成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); } } }, UnityEngine.Random.Range(0, 2) == 0 ? "qq" : "wx"); }); PayOrderButton.onClick.AddListener(() => { SDKLogManager.DebugLog("生成订单中~", SDKLogManager.DebugType.LogWarning); var payOrderData = new SDKData.PayOrderData() { orderId = SDKData.PayOrderData.GetCurrentTimeMiss(), userid = sdkmanager.SDK_Id, amount = 6, productId = "10001", productName = "60钻石", productDesc = "60钻石", callbackMessage = "回调给服务器时的附加消息", productCount = 1, callbackUrl = "http://111.231.206.145/juhe/u9Pay/payCallBack", roleID = "roleiid", roleName = "roleiid", //角色名字 zoneID = 2, //区id zoneName = "2区", //区名字 orderTime = SDKData.PayOrderData.GetCurrentTimeMiss(), extra = "", gamename = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"), ratio = 10,//充值比例 }; payOrderData.extra = "" + payOrderData.zoneID + "|" + payOrderData.roleID + "|" + payOrderData.productId; Action <OrderCreateModel> orderCreateAction = (order) => { payOrderData.amount = order.amount; payOrderData.callbackUrl = order.callbackurl; payOrderData.orderId = order.orderid; sdkmanager.PayItem(payOrderData); }; if (isRequestOrderId) { StartCoroutine(CreateOrder(orderCreateAction, payOrderData)); } else { orderCreateAction(new OrderCreateModel() { amount = (int)payOrderData.amount, callbackurl = payOrderData.callbackUrl, orderid = SDKData.PayOrderData.GetCurrentTimeMiss(), }); } // SDKManager.Instance.PayOrder(payOrderData); }); Action <SDKData.UpdatePlayerInfoType> onSaveRoleInfoClick = (type) => { SDKLogManager.DebugLog("正在保存角色信息!!", SDKLogManager.DebugType.LogWarning); var roleData = new SDKData.RoleData() { roleId = "123456", roleLevel = "22", roleName = "测试角色", createTime = System.DateTime.Now.Millisecond.ToString(), realmId = "1", realmName = "1区测试服", chapter = "1-1", arg = "这是一条保存角色信息的附加信息!", }; sdkmanager.UpdatePlayerInfo(roleData, type); }; SaveRoleButton.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.createRole); }); SaveRoleButton2.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.enterGame); }); SaveRoleButton3.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.levelUp); }); LogoutButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登出账号!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Logout(); sdkmanager.Logout(); }); OnGameExitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.OnGameExit(() => //{ // Debug.LogWarning("SDK 已经退出!"); //}); sdkmanager.ExitGame(); #if UNITY_EDITOR SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.gameObject.SetActive(true); #endif }); SaveUMengLevelButton.onClick.AddListener(() => { //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestEventID); }); SaveUMengCountButton.onClick.AddListener(() => { var data = new System.Collections.Generic.Dictionary <string, string>() { { "test1", "1" }, { "test2", "4" }, { "test3", "8" }, { "test4", "16" }, }; //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestComputingEvent, data); }); CheckSimulatorButton.onClick.AddListener(() => { CheckSimulator(); }); }