private static void SetStability(GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability stability)
        {
            string stabilityKey = string.Format(
                "{0}_{1}",
                KEY_INDICATOR_STABILITY,
                GamebaseUnitySDK.ZoneType.ToString().ToUpper());

            if (stability != null)
            {
                GamebaseIndicatorReport.stability = stability;
                PlayerPrefs.SetString(
                    stabilityKey,
                    JsonMapper.ToJson(stability));
                GamebaseLog.Debug("Launching Stability", typeof(GamebaseIndicatorReport));
            }
            else
            {
                if (PlayerPrefs.HasKey(stabilityKey) == true)
                {
                    GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability stabilityPreference = JsonMapper.ToObject <GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability>(PlayerPrefs.GetString(stabilityKey));
                    if (stabilityPreference.appKeyVersion >= GamebaseIndicatorReport.stability.appKeyVersion)
                    {
                        GamebaseIndicatorReport.stability = stabilityPreference;
                        GamebaseLog.Debug("Preference Stability", typeof(GamebaseIndicatorReport));
                    }
                    else
                    {
                        PlayerPrefs.SetString(
                            stabilityKey,
                            JsonMapper.ToJson(GamebaseIndicatorReport.stability));
                        GamebaseLog.Debug("Default Stability", typeof(GamebaseIndicatorReport));
                    }
                }
                else
                {
                    PlayerPrefs.SetString(
                        stabilityKey,
                        JsonMapper.ToJson(GamebaseIndicatorReport.stability));
                    GamebaseLog.Debug("Default Stability", typeof(GamebaseIndicatorReport));
                }
            }

            MergeDictionary(
                ref basicDataDictionary,
                new Dictionary <string, string>()
            {
                { GB_INTERNAL_REPORT_VERSION, GamebaseIndicatorReport.stability.appKeyVersion.ToString() }
            });
        }
        public static void Initialize(GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability stability, System.Action callback)
        {
#if UNITY_ANDROID
            platform = Platform.ANDROID;
#elif UNITY_IOS
            platform = Platform.IOS;
#elif UNITY_WEBGL
            platform = Platform.WEB;
#elif UNITY_STANDALONE
            platform = Platform.WINDOWS;
#endif

            string filePath = Path.Combine(Application.streamingAssetsPath, "Gamebase/defaultstability.json");

            GamebaseStringLoader lcalFileLoader = new GamebaseStringLoader();
            lcalFileLoader.LoadStringFromFile(
                filePath,
                (jsonString) =>
            {
                if (string.IsNullOrEmpty(jsonString) == false)
                {
                    GamebaseLog.Debug(
                        string.Format(
                            "jsonString : {0}",
                            jsonString),
                        typeof(GamebaseIndicatorReport));
                    Dictionary <string, GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability> stabilityDictionary = JsonMapper.ToObject <Dictionary <string, GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability> >(jsonString);
                    if (stabilityDictionary != null)
                    {
                        if (string.IsNullOrEmpty(GamebaseUnitySDK.ZoneType) == true)
                        {
                            GamebaseUnitySDK.ZoneType = "real";
                        }

                        GamebaseIndicatorReport.stability = stabilityDictionary[GamebaseUnitySDK.ZoneType.ToLower()];
                    }
                }

                CreateBaseData();
                SetStability(stability);
                CreateInstanceLogger();

                callback();
            });
        }
Beispiel #3
0
        public void Initialize(GamebaseRequest.GamebaseConfiguration configuration, int handle)
        {
            if (initializeHandle != -1)
            {
                GamebaseCallbackHandler.UnregisterCallback(initializeHandle);
            }

            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> initializeCallback = (launchingInfo, error) =>
            {
                GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability stability = null;
                if (error == null || error.code == GamebaseErrorCode.SUCCESS)
                {
                    #region Iap Setting
                    GamebaseLog.Debug("ToastSdk Initialize", this);
                    ToastSdk.Initialize();

                    if (PurchaseAdapterManager.Instance.CreateIDPAdapter("iapadapter") == true)
                    {
                        var iapConfiguration = new GamebaseRequest.Purchase.Configuration();
                        iapConfiguration.appKey    = launchingInfo.tcProduct.iap.appKey;
                        iapConfiguration.storeCode = configuration.storeCode;
                        PurchaseAdapterManager.Instance.SetConfiguration(iapConfiguration);
                    }

                    stability = launchingInfo.launching.tcgbClient.stability;
                    #endregion
                }

                GamebaseIndicatorReport.Initialize(
                    stability,
                    () => {
                    if (Gamebase.IsSuccess(error) == false)
                    {
                        initializeFailCount++;
                        if (initializeFailCount > GamebaseIndicatorReport.stability.initFailCount)
                        {
                            GamebaseIndicatorReport.SendIndicatorData(
                                GamebaseIndicatorReportType.LogType.INIT,
                                GamebaseIndicatorReportType.StabilityCode.GB_INIT_FAILED_MULTIPLE_TIMES,
                                GamebaseIndicatorReportType.LogLevel.WARN,
                                new Dictionary <string, string>()
                            {
                                { GamebaseIndicatorReportType.AdditionalKey.GB_CONFIGURATION, JsonMapper.ToJson(configuration) }
                            });
                            initializeFailCount = 0;
                        }
                    }
                    else
                    {
                        initializeFailCount = 0;
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> >(handle);

                    if (callback != null)
                    {
                        callback(launchingInfo, error);
                    }

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                });
            };

            initializeHandle = GamebaseCallbackHandler.RegisterCallback(initializeCallback);
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.CORE_TYPE, Init());
        }