diff --git a/Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs b/Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs index 1deb6ae..97f9ad3 100644 --- a/Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs +++ b/Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs @@ -1,11 +1,9 @@ -using UnityEngine; - -namespace Core.Ads.BridgeInterfaces +namespace Core.Ads.BridgeInterfaces { public interface IBannerBridge { + bool IsVisible(); void Show(BannerPositions position); void Hide(); - bool IsVisible(); } } \ No newline at end of file diff --git a/Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs b/Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs index 3dae8c4..9aca44f 100644 --- a/Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs +++ b/Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs @@ -1,11 +1,10 @@ -using System; -using UnityEngine; - -namespace Core.Ads.BridgeInterfaces +namespace Core.Ads.BridgeInterfaces { + public delegate void OnInterstitialEnded(); + public interface IInterstitialBridge { - Action OnEnded { get; set; } + event OnInterstitialEnded OnEnded; bool IsReady(); void Show(); bool IsVisible(); diff --git a/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs b/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs index 03bee88..f403e2d 100644 --- a/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs +++ b/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs @@ -42,22 +42,11 @@ namespace Core.Ads.Bridges.DemoAds private Vector2 CalculateBannerSize() { - int bannerHeight = 0; + float bannerSizePixels = Screen.height <= 400 ? 32 : Screen.height < 720 ? 50 : 90; + var percent = (100f / Screen.height) * bannerSizePixels; + var bannerSize = Screen.height * (percent / 100f); - if (Screen.height <= 400 * Mathf.RoundToInt(Screen.dpi / 160)) - { - bannerHeight = 32 * Mathf.RoundToInt(Screen.dpi / 160); - } - else if (Screen.height <= 720 * Mathf.RoundToInt(Screen.dpi / 160)) - { - bannerHeight = 50 * Mathf.RoundToInt(Screen.dpi / 160); - } - else - { - bannerHeight = 90 * Mathf.RoundToInt(Screen.dpi / 160); - } - - return new Vector2(bannerHeight * 6.4f, bannerHeight); + return new Vector2(bannerSize * 6.4f, bannerSize); } private Vector2 CalculateBannerPosition(Vector2 bannerSize) { diff --git a/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs b/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs index a3d4a55..618bd5c 100644 --- a/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs +++ b/Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs @@ -8,7 +8,7 @@ namespace Core.Ads.Bridges.DemoAds { public sealed class DemoInterstitialAds : MonoBehaviour, IInterstitialBridge { - public Action OnEnded { get; set; } + public event OnInterstitialEnded OnEnded = null; private bool _isInterstitialReady = false; diff --git a/Assets_DLL/Core/Audio/AudioController.cs b/Assets_DLL/Core/Audio/AudioController.cs index 2cf6421..ef7cbc4 100644 --- a/Assets_DLL/Core/Audio/AudioController.cs +++ b/Assets_DLL/Core/Audio/AudioController.cs @@ -9,6 +9,8 @@ namespace Core.Audio { public class AudioController : MonoBehaviour { + private static AudioController _controller = null; + private static AudioController2D _audio2D = null; private static AudioController3D _audio3D = null; @@ -16,7 +18,7 @@ namespace Core.Audio { GameObject audioParent = new GameObject("[AudioController]"); - audioParent.AddComponent(); + _controller = audioParent.AddComponent(); GameObject.DontDestroyOnLoad(audioParent); @@ -83,11 +85,11 @@ namespace Core.Audio } } - public static float PlayMusic(string name, bool isLoop = false) => - _audio2D.PlayMusic(name, isLoop); + public static void PlayMusic(string name) => + _controller.StartCoroutine(_audio2D.PlayMusic(name)); public static void StopMusic() => - _audio2D.StopMusic(); + _controller.StartCoroutine(_audio2D.StopMusic()); public static float PlaySound(string name, bool isLoop = false) => _audio2D.PlaySound(name, isLoop); diff --git a/Assets_DLL/Core/Audio/AudioController2D.cs b/Assets_DLL/Core/Audio/AudioController2D.cs index 9091512..c4f9344 100644 --- a/Assets_DLL/Core/Audio/AudioController2D.cs +++ b/Assets_DLL/Core/Audio/AudioController2D.cs @@ -5,6 +5,7 @@ using UnityEngine; using Core.Settings; using Core.Tools.Saves; using System; +using System.Collections; namespace Core.Audio { @@ -65,7 +66,7 @@ namespace Core.Audio } } - internal float PlayMusic(string name, bool isLoop = true) + internal IEnumerator PlayMusic(string name) { if (_musicSource == null) { @@ -74,23 +75,49 @@ namespace Core.Audio _musicSource.volume = CoreSettings.data.musicVolume * MusicVolume; } + while (_musicSource.volume > 0f) + { + yield return null; + _musicSource.volume -= Time.deltaTime / 2f; + } + + _musicSource.volume = 0; + if (_musicAndSounds.ContainsKey(name)) { _musicSource.clip = _musicAndSounds[name]; - _musicSource.loop = isLoop; + _musicSource.loop = true; _musicSource.gameObject.SetActive(true); + _musicSource.enabled = true; + _musicSource.Play(); - return _musicAndSounds[name].length; + while (_musicSource.volume < MusicVolume) + { + yield return null; + _musicSource.volume += Time.deltaTime / 2f; + } + + _musicSource.volume = MusicVolume; } else throw new ArgumentNullException($"music \"{name}\" not found"); } - internal void StopMusic() + internal IEnumerator StopMusic() { + while (_musicSource.volume > 0f) + { + yield return null; + _musicSource.volume -= Time.deltaTime / 2f; + } + + _musicSource.volume = 0; + _musicSource.Stop(); + + _musicSource.volume = MusicVolume; } internal float PlaySound(string name, bool isLoop = false) @@ -112,6 +139,8 @@ namespace Core.Audio playSource.loop = isLoop; playSource.gameObject.SetActive(true); + playSource.enabled = true; + playSource.Play(); return _musicAndSounds[name].length; @@ -149,6 +178,8 @@ namespace Core.Audio playSource.clip = _voicesDictionary[LocalizationManager.CurrentLanguage][name]; playSource.gameObject.SetActive(true); + playSource.enabled = true; + playSource.Play(); return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length; diff --git a/Assets_DLL/Core/Audio/AudioController3D.cs b/Assets_DLL/Core/Audio/AudioController3D.cs index 707b910..9a6f020 100644 --- a/Assets_DLL/Core/Audio/AudioController3D.cs +++ b/Assets_DLL/Core/Audio/AudioController3D.cs @@ -52,6 +52,8 @@ namespace Core.Audio { AudioSource playSource = _soundsSources.Where(s => s != null && !s.isPlaying).FirstOrDefault(); + Debug.LogError($"enable: {playSource.enabled}, active: {playSource.gameObject.activeSelf}"); + if (playSource == null) { GameObject sound = new GameObject("Sound"); @@ -78,6 +80,8 @@ namespace Core.Audio playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.gameObject.SetActive(true); + playSource.enabled = true; + playSource.Play(); return _musicAndSounds[name].length; @@ -126,6 +130,8 @@ namespace Core.Audio playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.gameObject.SetActive(true); + playSource.enabled = true; + playSource.Play(); return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length; diff --git a/Assets_DLL/Core/Audio/PlayAudioFile.cs b/Assets_DLL/Core/Audio/PlayAudioFile.cs index 79f422d..b2a89db 100644 --- a/Assets_DLL/Core/Audio/PlayAudioFile.cs +++ b/Assets_DLL/Core/Audio/PlayAudioFile.cs @@ -118,8 +118,8 @@ namespace Core.Audio { case AudioFileType.Music: - time = AudioController.PlayMusic(_audioFileNames[Random.Range(0, _audioFileNames.Length)], _loop); - break; + AudioController.PlayMusic(_audioFileNames[Random.Range(0, _audioFileNames.Length)]); + yield break; case AudioFileType.Sound: diff --git a/Assets_DLL/Core/SceneManagement/SceneLoader.cs b/Assets_DLL/Core/SceneManagement/SceneLoader.cs index 9da7da8..d5abafd 100644 --- a/Assets_DLL/Core/SceneManagement/SceneLoader.cs +++ b/Assets_DLL/Core/SceneManagement/SceneLoader.cs @@ -5,6 +5,7 @@ using UnityEngine.SceneManagement; using Core.Settings; using Core.Ads; using System.Linq; +using Core.Tools.Saves; namespace Core.SceneManagement { @@ -58,6 +59,8 @@ namespace Core.SceneManagement OnLoadedStart?.Invoke(scene); _current.StartCoroutine(StartLoad(scene)); + + SaveManager.Save(); } private static IEnumerator StartLoad(string scene) diff --git a/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll b/Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll index c6e5a26..99a763c 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 5244097..29f93ac 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/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.CopyComplete b/Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.CopyComplete new file mode 100644 index 0000000..e69de29