public static void InitializeSDK(System.Action <string, bool> callback) { if (mInitialized) { EB.Debug.LogWarning("UCSDKManager.InitializeSDK: Initialized"); callback(null, true); return; } if (Application.platform != RuntimePlatform.Android) { callback("Not support", false); return; } mInitCallback += callback; if (!mInitializing) { mInitializing = true; SparxUCSDKManager.InitCallback += delegate(bool sucess, string msg) { EB.Debug.Log("InitCallback: sucess={0}, msg={1}", sucess, msg); mInitializing = false; if (sucess) { mInitialized = true; } if (mInitCallback != null) { mInitCallback(mInitialized ? null : msg, mInitialized); mInitCallback = null; } }; new GameObject("uc_plugin_listener", typeof(SparxUCSDKManager)); SDKParams param = new SDKParams(); param.Add(SDKParamKey.DEBUG_MODE, false); param.Add(SDKParamKey.GAME_ID, defaultGameId); GameParamInfo info = new GameParamInfo(); info.GameId = defaultGameId; info.Orientation = UCOrientation.LANDSCAPE; info.EnablePayHistory = true; info.EnableUserChange = true; param.Add(SDKParamKey.GAME_PARAMS, info); UCGameSdk.initSDK(param); } }
public void InitializeSDK(object options, System.Action <string, bool> callback) { if (mInitialized) { EB.Debug.LogWarning("UCSDKManager.InitializeSDK: Initialized"); callback(null, true); return; } if (Application.platform != RuntimePlatform.Android) { callback(null, false); return; } mInitCallback += callback; mNotifyUrl = EB.Dot.String("notifyUrl", options, mNotifyUrl); bool debugMode = EB.Dot.Bool("debugMode", options, false); int gameId = EB.Dot.Integer("gameId", options, 0); if (!mInitializing) { mInitializing = true; Hub.RunInBackground = true; new GameObject("uc_plugin_listener", typeof(SparxUCSDKManager)); SDKParams param = new SDKParams(); param.Add(SDKParamKey.DEBUG_MODE, debugMode); param.Add(SDKParamKey.GAME_ID, gameId); GameParamInfo info = new GameParamInfo(); info.GameId = gameId; info.Orientation = UCOrientation.LANDSCAPE; info.EnablePayHistory = true; info.EnableUserChange = true; param.Add(SDKParamKey.GAME_PARAMS, info); UCGameSdk.initSDK(param); } }
public void SubmitLoginData(int level) { if (Application.platform == RuntimePlatform.Android) { if (!mInitialized) { EB.Debug.LogError("UCSDKManager.SubmitLoginData: not initialized"); return; } var user = Hub.LoginManager.LocalUser; if (user == null) { return; } var worlds = Hub.LoginManager.GameWorlds; var world = System.Array.Find(worlds, w => w.Id == user.WorldId); string worldName = world != null ? world.Name : (worlds.Length > 0 ? worlds[0].Name : "Default"); SDKParams loginGameRole = new SDKParams(); loginGameRole.Add(SDKParamKey.STRING_ZONE_ID, user.WorldId.ToString()); loginGameRole.Add(SDKParamKey.STRING_ZONE_NAME, worldName); loginGameRole.Add(SDKParamKey.STRING_ROLE_ID, user.Id.Value.ToString()); loginGameRole.Add(SDKParamKey.STRING_ROLE_NAME, user.Name); loginGameRole.Add(SDKParamKey.LONG_ROLE_LEVEL, (long)level); loginGameRole.Add(SDKParamKey.LONG_ROLE_CTIME, (long)user.CreateTime); UCGameSdk.submitRoleData(loginGameRole); } }
public void Pay(EB.IAP.Item item, EB.IAP.Transaction transaction, System.Action <int, object> callback) { if (!mInitialized) { EB.Debug.LogError("UCSDKManager.Pay: not initialized"); callback(UCStatusCode.NO_INIT, null); return; } mPayCallback += callback; var user = Hub.Instance.LoginManager.LocalUser; long uid = user.Id.Value; //int worldId = user.WorldId; string name = user.Name; int level = user.Level; object extraInfo = EB.JSON.Parse(transaction.payload); SDKParams param = new SDKParams(); param.Add(SDKParamKey.ACCOUNT_ID, EB.Dot.String("accountId", extraInfo, "0")); param.Add(SDKParamKey.CP_ORDER_ID, EB.Dot.String("cpOrderId", extraInfo, transaction.transactionId)); param.Add(SDKParamKey.AMOUNT, EB.Dot.String("amount", extraInfo, string.Format("{0:N2}", item.cost))); param.Add(SDKParamKey.SERVER_ID, EB.Dot.String("serverId", extraInfo, "0")); param.Add(SDKParamKey.ROLE_ID, EB.Dot.String("roleId", extraInfo, uid.ToString())); param.Add(SDKParamKey.ROLE_NAME, EB.Dot.String("roleName", extraInfo, name)); param.Add(SDKParamKey.GRADE, EB.Dot.String("grade", extraInfo, level.ToString())); param.Add(SDKParamKey.CALLBACK_INFO, EB.Dot.String("callbackInfo", extraInfo, "0")); param.Add(SDKParamKey.NOTIFY_URL, EB.Dot.String("notifyUrl", extraInfo, mNotifyUrl)); param.Add(SDKParamKey.SIGN_TYPE, "MD5"); param.Add(SDKParamKey.SIGN, transaction.signature); UCGameSdk.pay(param); }