diff --git a/Assets/Prototype/Core/Core.dll b/Assets/Prototype/Core/Core.dll index 0f13ba8..9cd189f 100644 Binary files a/Assets/Prototype/Core/Core.dll and b/Assets/Prototype/Core/Core.dll differ diff --git a/Assets_DLL/Core/Ads/AdsManager.cs b/Assets_DLL/Core/Ads/AdsManager.cs index acbc20e..0c22465 100644 --- a/Assets_DLL/Core/Ads/AdsManager.cs +++ b/Assets_DLL/Core/Ads/AdsManager.cs @@ -31,7 +31,7 @@ namespace Core.Ads else { if (CoreSettings.data.adsBridgeObiect == null) - throw new NullReferenceException("ads bridge object is null"); + throw new NullReferenceException("Ads bridge object is null"); bridge = GameObject.Instantiate(CoreSettings.data.adsBridgeObiect, holder.transform); } @@ -44,7 +44,7 @@ namespace Core.Ads _interstitial = bridge.GetComponent(); if (_interstitial == null) - throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); + throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); _interstitial.OnEnded += () => OnInterstitialShowed?.Invoke(); } @@ -57,14 +57,14 @@ namespace Core.Ads _banner = bridge.GetComponent(); if (_banner == null) - throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); + throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); PurchaseManager.OnPurchaseSuccess += (productId) => { - if (!CoreSettings.data.nonConsumableProducts.Contains(productId)) + if (CoreSettings.data.IsProductConsumable(productId)) return; - if (CoreSettings.data.nonConsumableProductsDisableAds[CoreSettings.data.nonConsumableProducts.IndexOf(productId)]) + if (CoreSettings.data.IsOnAdsProduct(productId)) HideBanner(); }; } @@ -77,17 +77,15 @@ namespace Core.Ads _rewarded = bridge.GetComponent(); if (_rewarded == null) - throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); + throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); } - - } public static bool IsAdsDisabled() { for (int i = 0; i < CoreSettings.data.nonConsumableProducts.Count; i++) { - if (CoreSettings.data.nonConsumableProductsDisableAds[i] && PurchaseManager.IsProductPurchased(CoreSettings.data.nonConsumableProducts[i])) + if (PurchaseManager.IsProductPurchased(CoreSettings.data.nonConsumableProducts[i])) return true; } @@ -100,7 +98,7 @@ namespace Core.Ads return false; if (_interstitial == null) - throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); + throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); if (CoreSettings.data.needInterstitial) return _interstitial.IsReady(); @@ -111,7 +109,7 @@ namespace Core.Ads public static bool IsInterstitialVisible() { if (_interstitial == null) - throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); + throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); if (CoreSettings.data.needInterstitial) return _interstitial.IsVisible(); @@ -121,11 +119,13 @@ namespace Core.Ads public static void ShowInterstitial() { + Debug.Log("Called show interstitial"); + if (IsAdsDisabled()) return; if (_interstitial == null) - throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); + throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); if (CoreSettings.data.needInterstitial) _interstitial.Show(); @@ -139,7 +139,7 @@ namespace Core.Ads return false; if (_rewarded == null) - throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); + throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); if (CoreSettings.data.needRewarded) return _rewarded.IsReady(); @@ -149,11 +149,13 @@ namespace Core.Ads public static void ShowRewarded(Action onSucces, Action onFailed) { + Debug.Log("Called show rewarded"); + if (IsAdsDisabled()) return; if (_rewarded == null) - throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); + throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); if (CoreSettings.data.needRewarded) _rewarded.Show(onSucces, onFailed); @@ -164,7 +166,7 @@ namespace Core.Ads public static bool IsBannerVisible() { if (_banner == null) - throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); + throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); if (CoreSettings.data.needBanner) _banner.IsVisible(); @@ -176,11 +178,13 @@ namespace Core.Ads public static void ShowBanner(BannerPositions position) { + Debug.Log("Called show banner"); + if (IsAdsDisabled()) return; if (_banner == null) - throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); + throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); if (CoreSettings.data.needBanner) _banner.Show(position); @@ -190,8 +194,10 @@ namespace Core.Ads public static void HideBanner() { + Debug.Log("Called hide banner"); + if (_banner == null) - throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); + throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); if (CoreSettings.data.needBanner) _banner.Hide(); diff --git a/Assets_DLL/Core/Ads/RewardedButton.cs b/Assets_DLL/Core/Ads/RewardedButton.cs index 70d5b94..bb725e4 100644 --- a/Assets_DLL/Core/Ads/RewardedButton.cs +++ b/Assets_DLL/Core/Ads/RewardedButton.cs @@ -49,10 +49,10 @@ namespace Core.Ads private void CheckAdsEnablingAfterPurchasing(string productId) { - if (!CoreSettings.data.nonConsumableProducts.Contains(productId)) + if (CoreSettings.data.IsProductConsumable(productId)) return; - if (CoreSettings.data.nonConsumableProductsDisableAds[CoreSettings.data.nonConsumableProducts.IndexOf(productId)]) + if (CoreSettings.data.IsOnAdsProduct(productId)) gameObject.SetActive(false); } } diff --git a/Assets_DLL/Core/Audio/AudioController.cs b/Assets_DLL/Core/Audio/AudioController.cs index 674c4e1..5b0aab3 100644 --- a/Assets_DLL/Core/Audio/AudioController.cs +++ b/Assets_DLL/Core/Audio/AudioController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; using Core.Settings; +using Core.Tools.Saves; namespace Core.Audio { @@ -48,30 +49,30 @@ namespace Core.Audio public static float MusicVolume { - get => PlayerPrefs.GetFloat("MusicVolume", 1f); + get => SaveManager.GetFloat("MusicVolume", 1f); set { - PlayerPrefs.SetFloat("MusicVolume", value); + SaveManager.SetFloat("MusicVolume", value); _audio2D.MusicVolume = value; } } public static float SoundsVolume { - get => PlayerPrefs.GetFloat("MusicVolume", 1f); + get => SaveManager.GetFloat("MusicVolume", 1f); set { - PlayerPrefs.SetFloat("MusicVolume", value); + SaveManager.SetFloat("MusicVolume", value); _audio2D.SoundsVolume = value; } } public static float VoicesVolume { - get => PlayerPrefs.GetFloat("MusicVolume", 1f); + get => SaveManager.GetFloat("MusicVolume", 1f); set { - PlayerPrefs.SetFloat("MusicVolume", value); + SaveManager.SetFloat("MusicVolume", value); _audio2D.VoicesVolume = value; } } diff --git a/Assets_DLL/Core/Audio/AudioController2D.cs b/Assets_DLL/Core/Audio/AudioController2D.cs index b8cf357..6af05c2 100644 --- a/Assets_DLL/Core/Audio/AudioController2D.cs +++ b/Assets_DLL/Core/Audio/AudioController2D.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; using Core.Settings; +using Core.Tools.Saves; namespace Core.Audio { @@ -39,13 +40,13 @@ namespace Core.Audio internal float MusicVolume { - get => PlayerPrefs.GetFloat("MusicVolume", 1f); + get => SaveManager.GetFloat("MusicVolume", 1f); set => _musicSource.volume = CoreSettings.data.musicVolume * value; } internal float SoundsVolume { - get => PlayerPrefs.GetFloat("MusicVolume", 1f); + get => SaveManager.GetFloat("MusicVolume", 1f); set { for (int i = 0; i < _soundsSources.Count; i++) diff --git a/Assets_DLL/Core/IAP/PurchaseButton.cs b/Assets_DLL/Core/IAP/PurchaseButton.cs index 300f1f7..7e477fe 100644 --- a/Assets_DLL/Core/IAP/PurchaseButton.cs +++ b/Assets_DLL/Core/IAP/PurchaseButton.cs @@ -1,4 +1,5 @@ using Core.IAP; +using Core.Settings; using UnityEngine; using UnityEngine.Events; using UnityEngine.Purchasing; @@ -40,7 +41,7 @@ namespace Core.Ads private void CheckAdsEnablingAfterPurchasing(string productId) { - if (_productId == productId) + if (_productId == productId && !CoreSettings.data.IsProductConsumable(productId)) { _onSucces?.Invoke(); gameObject.SetActive(false); diff --git a/Assets_DLL/Core/IAP/PurchaseManagerBase.cs b/Assets_DLL/Core/IAP/PurchaseManagerBase.cs index c9afda0..552c0f2 100644 --- a/Assets_DLL/Core/IAP/PurchaseManagerBase.cs +++ b/Assets_DLL/Core/IAP/PurchaseManagerBase.cs @@ -1,4 +1,5 @@ using Core.Settings; +using Core.Tools.Saves; using System; using UnityEngine; using UnityEngine.Purchasing; @@ -17,7 +18,7 @@ namespace Core.IAP _storeController != null && _storeExtensionProvider != null; public bool IsProductPurchased(string productID) => - PlayerPrefs.GetString(productID.ToString() + "_purchased", "false") == "true"; + SaveManager.GetString(productID.ToString() + "_purchased", "false") == "true"; public void InitializePurchasing() { @@ -36,7 +37,8 @@ namespace Core.IAP { if (Application.isEditor) { - PlayerPrefs.SetString(productId + "_purchased", "true"); + if (!CoreSettings.data.IsProductConsumable(productId)) + SaveManager.SetString(productId + "_purchased", "true"); if (OnPurchaseSuccess != null) OnPurchaseSuccess(productId); @@ -72,12 +74,12 @@ namespace Core.IAP { string price = _storeController.products.WithID(productID).metadata.localizedPriceString; - PlayerPrefs.SetString(productID + "_last_price", price); + SaveManager.SetString(productID + "_last_price", price); return price; } else - return PlayerPrefs.GetString(productID + "_last_price", "0.99$"); + return SaveManager.GetString(productID + "_last_price", "0.99$"); } public void OnInitialized(IStoreController controller, IExtensionProvider extensions) @@ -101,7 +103,8 @@ namespace Core.IAP { string productId = purchaseEvent.purchasedProduct.definition.id; - PlayerPrefs.SetString(productId + "_purchased", "true"); + if (!CoreSettings.data.IsProductConsumable(productId)) + SaveManager.SetString(productId + "_purchased", "true"); OnPurchaseSuccess?.Invoke(productId); diff --git a/Assets_DLL/Core/Localization/LocalizationManager.cs b/Assets_DLL/Core/Localization/LocalizationManager.cs index 1f4b88c..e496968 100644 --- a/Assets_DLL/Core/Localization/LocalizationManager.cs +++ b/Assets_DLL/Core/Localization/LocalizationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEngine; using Core.Settings; using Core.Localization.Utils; +using Core.Tools.Saves; namespace Core.Localization { @@ -17,11 +18,11 @@ namespace Core.Localization public static SystemLanguage CurrentLanguage { - get => ConvertToAvailableLanguage((SystemLanguage)PlayerPrefs.GetInt("CurrentLanguage", (int)Application.systemLanguage)); + get => ConvertToAvailableLanguage((SystemLanguage)SaveManager.GetInt("CurrentLanguage", (int)Application.systemLanguage)); set { SystemLanguage language = ConvertToAvailableLanguage(value); - PlayerPrefs.SetInt("CurrentLanguage", (int)language); + SaveManager.SetInt("CurrentLanguage", (int)language); OnLocalizationChanged?.Invoke(language); } } @@ -114,10 +115,10 @@ namespace Core.Localization if (_dictionary.ContainsKey(CurrentLanguage)) return _dictionary[CurrentLanguage][_keys.IndexOf(key)]; else - throw new KeyNotFoundException($"language \"{CurrentLanguage}\" not found"); + throw new KeyNotFoundException($"Language \"{CurrentLanguage}\" not found"); } else - throw new KeyNotFoundException($"key \"{key}\" not found"); + throw new KeyNotFoundException($"Key \"{key}\" not found"); } private static SystemLanguage ConvertToAvailableLanguage(SystemLanguage language) diff --git a/Assets_DLL/Core/SceneManagement/SceneLoader.cs b/Assets_DLL/Core/SceneManagement/SceneLoader.cs index 0993297..9da7da8 100644 --- a/Assets_DLL/Core/SceneManagement/SceneLoader.cs +++ b/Assets_DLL/Core/SceneManagement/SceneLoader.cs @@ -53,7 +53,7 @@ namespace Core.SceneManagement public static void LoadScene(string scene) { if (_isSceneLoading) - throw new InvalidOperationException("scene is already loading"); + throw new InvalidOperationException("Scene is already loading"); OnLoadedStart?.Invoke(scene); @@ -64,6 +64,8 @@ namespace Core.SceneManagement { _isSceneLoading = true; + Debug.Log($"Started loading scene \"{scene}\""); + if (CoreSettings.data.needBanner) AdsManager.HideBanner(); diff --git a/Assets_DLL/Core/Settings/CoreSettingsData.cs b/Assets_DLL/Core/Settings/CoreSettingsData.cs index 0433d81..11c97ef 100644 --- a/Assets_DLL/Core/Settings/CoreSettingsData.cs +++ b/Assets_DLL/Core/Settings/CoreSettingsData.cs @@ -51,6 +51,17 @@ namespace Core.Settings public List nonConsumableProducts = new List(); public List nonConsumableProductsDisableAds = new List(); + public bool IsProductConsumable(string productId) => + consumableProducts.Contains(productId); + + public bool IsOnAdsProduct(string productId) + { + if (IsProductConsumable(productId)) + return false; + + return nonConsumableProductsDisableAds[nonConsumableProducts.IndexOf(productId)]; + } + #endregion #region Localization diff --git a/Assets_DLL/Core/Tools/Pool/Particles/ParticlesPool.cs b/Assets_DLL/Core/Tools/Pool/Particles/ParticlesPool.cs index a45e9d2..053d3ef 100644 --- a/Assets_DLL/Core/Tools/Pool/Particles/ParticlesPool.cs +++ b/Assets_DLL/Core/Tools/Pool/Particles/ParticlesPool.cs @@ -26,7 +26,7 @@ namespace Core.Tools.Pool.Particles Particle particle = _current._particles.Where(p => p.ID == id).FirstOrDefault(); if (particle == null) - throw new KeyNotFoundException($"particle with id={id} not found!!!"); + throw new KeyNotFoundException($"Particle with id={id} not found!!!"); ParticleSystem particleSystem = particle.GetParticleFromPool(); diff --git a/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.csproj.AssemblyReference.cache b/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.csproj.AssemblyReference.cache index 1a280c5..f5e894a 100644 Binary files a/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.csproj.AssemblyReference.cache and b/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.csproj.AssemblyReference.cache differ diff --git a/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll b/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll index 0f13ba8..9cd189f 100644 Binary files a/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll and b/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll differ diff --git a/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache b/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache index f5e894a..896379c 100644 Binary files a/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache and b/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache differ diff --git a/Builds/Core_1.8.2.unitypackage b/Builds/Core_1.8.2.unitypackage new file mode 100644 index 0000000..f4aa424 Binary files /dev/null and b/Builds/Core_1.8.2.unitypackage differ