public void Refresh() { RankGameItemManager ranksManager = LevelController.Ranks(); for (int r = ranksManager.Items.Length; r > 0; r--) { Rank rank = ranksManager.GetItem(r); rank.LoadData(); GameObject pageObject = Instantiate(pagePrefab); pageObject.SetActive(false); pageObject.transform.SetParent(transform, false); Text _rankSignText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(pageObject, "RankName", true); _rankSignText.text = LocaliseText.Get(rank.JsonData.GetString("name")); ItemsRange range = LevelController.RankPacksRange(rank); for (int i = range.From; i < range.To + 1; i++) { Pack pack = LevelController.Packs().GetItem(i); GameObject newObject = Instantiate(Prefab); newObject.GetComponent <PackItem>().Number = i; newObject.transform.SetParent(pageObject.transform, false); newObject.GetComponent <Button>().onClick.AddListener(() => { LevelsListController.Instance.OpenPackButton(pack); }); buttons.Add(newObject); } } CustomUI_ScrollRectOcclusion _occ = GetComponent <CustomUI_ScrollRectOcclusion>(); _occ.Init(); }
protected override void GameSetup() { // secure preferences PreferencesFactory.UseSecurePrefs = SecurePreferences; if (SecurePreferences) { if (string.IsNullOrEmpty(PreferencesPassPhrase)) { Debug.LogWarning("You have not set a custom pass phrase in GameManager | Player Preferences. Please correct for improved security."); } else { PreferencesFactory.PassPhrase = PreferencesPassPhrase; } PreferencesFactory.AutoConvertUnsecurePrefs = AutoConvertUnsecurePrefs; } StartupLevels = NumberOfAutoCreatedLevels; int NumberOfAdditionalCreatedLevels = PreferencesFactory.GetInt(Constants.KeyNumberOfAdditionalCreatedLevels); NumberOfAutoCreatedLevels += NumberOfAdditionalCreatedLevels; string FirstAppStartDate = PreferencesFactory.GetString(Constants.KeyFirstAppStartDate, null); if (FirstAppStartDate == null) { PreferencesFactory.SetString(Constants.KeyFirstAppStartDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); } PreferencesFactory.SetString(Constants.KeyLastAppStartDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); int TimesAppStarted = PreferencesFactory.GetInt(Constants.KeyTimesAppStarted, 0); PreferencesFactory.SetInt(Constants.KeyTimesAppStarted, TimesAppStarted + 1); base.GameSetup(); if (PlayerPrefs.GetInt("ManualChangedLanguage", 0) == 0) { #if UNITY_ANDROID || UNITY_EDITOR string savedLanguage = PreferencesFactory.GetString("Language", useSecurePrefs: false); string systemLanguage = DeviceLanguage(); // user does not changed his language manual // and system language is different from previous auto-detected if (systemLanguage != savedLanguage) { LanguageController.ChangeLanguage(systemLanguage); } #endif #if UNITY_IOS IOSNativeUtility.OnLocaleLoaded += GetLocale; IOSNativeUtility.Instance.GetLocale(); #endif } Packs = new PackGameItemManager(); if (LevelSetupMode == GameItemSetupMode.FromResources) { Packs.Load(1, NumberOfAutoCreatedPacks); } Ranks = new RankGameItemManager(); if (LevelSetupMode == GameItemSetupMode.FromResources) { Ranks.Load(1, NumberOfAutoCreatedRanks); } Rank rank = Ranks.GetItem(1); if (!rank.IsUnlocked) { rank.IsUnlocked = true; // first rank is unlocked by default rank.UpdatePlayerPrefs(); } Pack pack = Packs.GetItem(1); if (!pack.IsUnlocked) { pack.IsUnlocked = true; // first pack is unlocked by default pack.UpdatePlayerPrefs(); } Level level = Levels.GetItem(1); if (!level.IsUnlocked) { level.IsUnlocked = true; // first level is unlocked by default level.UpdatePlayerPrefs(); } GameManager.SafeAddListener <UserNotificationsChangedMessage>(UserNotificationsChangedHandler); GameManager.SafeAddListener <LocalisationChangedMessage>(LocalisationHandler); // bug fix in gameframework when user loose all his lives and start game again and Lives back to full if (FirstAppStartDate != null) { // but only after first start ever Player.Lives = Player.GetSettingInt("Lives", 0); } if (FirstAppStartDate == null) { // first start PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, 1); } // Advertisement.Initialize(Constants.UnityAdsGameId); if (BackGroundAudioVolume > Constants.DefaultAudioVolume) { BackGroundAudioVolume = Constants.DefaultAudioVolume; } if (EffectAudioVolume > Constants.DefaultAudioVolume) { EffectAudioVolume = Constants.DefaultAudioVolume; } _currentBackgroundSoundVolume = BackGroundAudioVolume; if (!SoundEnabled()) { BackGroundAudioSource.Stop(); } #if UNITY_IPHONE SA.IOSNative.Core.AppController.Subscribe(); SA.IOSNative.Core.AppController.OnApplicationDidReceiveMemoryWarning += OnApplicationDidReceiveMemoryWarning; #endif #if !UNITY_EDITOR CancelLocalNotifications(); RegisterLocalNotifications(); #endif }