コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        /// <summary>
        /// 初始化SDK
        /// </summary>
        public static void initSDK(SDKParams sdkParams)
        {
            bool debugMode = false;

            if (sdkParams.ContainsKey(SDKParamKey.DEBUG_MODE))
            {
                debugMode = (bool)sdkParams[SDKParamKey.DEBUG_MODE];
            }

            string gameId = string.Empty;

            if (sdkParams.ContainsKey(SDKParamKey.GAME_ID))
            {
                gameId = sdkParams[SDKParamKey.GAME_ID].ToString();
            }

            GameParamInfo gameInfo = new GameParamInfo();

            if (sdkParams.ContainsKey(SDKParamKey.GAME_PARAMS))
            {
                gameInfo = (GameParamInfo)sdkParams[SDKParamKey.GAME_PARAMS];
            }

            int orientation;

            switch (gameInfo.Orientation)
            {
            case UCOrientation.PORTRAIT:
                orientation = 0;
                break;

            case UCOrientation.LANDSCAPE:
                orientation = 1;
                break;

            default:
                orientation = 0;
                break;
            }
            callSdkApi("initSDK", debugMode, gameInfo.GameId, gameInfo.EnablePayHistory, gameInfo.EnableUserChange, orientation);
        }