diff --git a/Assets/Prototype/Core/Core.dll b/Assets/Prototype/Core/Core.dll index 5917e14..ee36347 100644 Binary files a/Assets/Prototype/Core/Core.dll and b/Assets/Prototype/Core/Core.dll differ diff --git a/Assets/Prototype/Core/CoreEditor.dll b/Assets/Prototype/Core/CoreEditor.dll index 10af518..39528b2 100644 Binary files a/Assets/Prototype/Core/CoreEditor.dll and b/Assets/Prototype/Core/CoreEditor.dll differ diff --git a/Assets_DLL/Core/Ads/AdsManager.cs b/Assets_DLL/Core/Ads/AdsManager.cs index 0c22465..d70ca9c 100644 --- a/Assets_DLL/Core/Ads/AdsManager.cs +++ b/Assets_DLL/Core/Ads/AdsManager.cs @@ -17,6 +17,9 @@ namespace Core.Ads internal static void Init() { + if (!CoreSettings.data.needInterstitial && !CoreSettings.data.needBanner && !CoreSettings.data.needRewarded) + return; + GameObject holder = new GameObject("[AdsManager]"); GameObject bridge = null; diff --git a/Assets_DLL/Core/Audio/AudioController.cs b/Assets_DLL/Core/Audio/AudioController.cs index 75836ce..2cf6421 100644 --- a/Assets_DLL/Core/Audio/AudioController.cs +++ b/Assets_DLL/Core/Audio/AudioController.cs @@ -83,8 +83,8 @@ namespace Core.Audio } } - public static float PlayMusic(string name) => - _audio2D.PlayMusic(name); + public static float PlayMusic(string name, bool isLoop = false) => + _audio2D.PlayMusic(name, isLoop); public static void StopMusic() => _audio2D.StopMusic(); @@ -121,7 +121,7 @@ namespace Core.Audio { AudioListener listener = FindObjectOfType(); - if (listener == null) + if (listener != null) _currentTarget = listener.transform; } else diff --git a/Assets_DLL/Core/Audio/AudioController2D.cs b/Assets_DLL/Core/Audio/AudioController2D.cs index 294eb66..c9b3deb 100644 --- a/Assets_DLL/Core/Audio/AudioController2D.cs +++ b/Assets_DLL/Core/Audio/AudioController2D.cs @@ -65,12 +65,11 @@ namespace Core.Audio } } - internal float PlayMusic(string name) + internal float PlayMusic(string name, bool isLoop = true) { if (_musicSource == null) { _musicSource = _musicParent.AddComponent(); - _musicSource.loop = true; _musicSource.playOnAwake = false; _musicSource.volume = CoreSettings.data.musicVolume * MusicVolume; } @@ -78,6 +77,7 @@ namespace Core.Audio if (_musicAndSounds.ContainsKey(name)) { _musicSource.clip = _musicAndSounds[name]; + _musicSource.loop = isLoop; _musicSource.Play(); return _musicAndSounds[name].length; diff --git a/Assets_DLL/Core/Audio/AudioController3D.cs b/Assets_DLL/Core/Audio/AudioController3D.cs index 33e5c27..51f9f34 100644 --- a/Assets_DLL/Core/Audio/AudioController3D.cs +++ b/Assets_DLL/Core/Audio/AudioController3D.cs @@ -16,10 +16,6 @@ namespace Core.Audio _voicesDictionary = voicesDictionary; } - private GameObject _musicParent = null; - private GameObject _soundsParent = null; - private GameObject _voicesParent = null; - private List _soundsSources = new List(); private List _voicesSources = new List(); @@ -58,9 +54,13 @@ namespace Core.Audio if (playSource == null) { - playSource = _soundsParent.AddComponent(); + GameObject sound = new GameObject("Sound"); + playSource = sound.AddComponent(); playSource.playOnAwake = false; playSource.volume = CoreSettings.data.soundsVolume * SoundsVolume; + playSource.spatialBlend = 1f; + playSource.rolloffMode = AudioRolloffMode.Custom; + playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); _soundsSources.Add(playSource); } @@ -73,6 +73,9 @@ namespace Core.Audio playSource.maxDistance = maxDistance; playSource.transform.SetParent(target); playSource.transform.localPosition = Vector3.zero; + playSource.spatialBlend = 1f; + playSource.rolloffMode = AudioRolloffMode.Custom; + playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.Play(); return _musicAndSounds[name].length; @@ -95,10 +98,14 @@ namespace Core.Audio if (playSource == null) { - playSource = _voicesParent.AddComponent(); + GameObject voice = new GameObject("Voice"); + playSource = voice.AddComponent(); playSource.loop = false; playSource.playOnAwake = false; playSource.volume = CoreSettings.data.voicesVolume * VoicesVolume; + playSource.spatialBlend = 1f; + playSource.rolloffMode = AudioRolloffMode.Custom; + playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); _voicesSources.Add(playSource); } @@ -112,6 +119,9 @@ namespace Core.Audio playSource.maxDistance = maxDistance; playSource.transform.SetParent(target); playSource.transform.localPosition = Vector3.zero; + playSource.spatialBlend = 1f; + playSource.rolloffMode = AudioRolloffMode.Custom; + playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.Play(); return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length; diff --git a/Assets_DLL/Core/Audio/PlayAudioFile.cs b/Assets_DLL/Core/Audio/PlayAudioFile.cs new file mode 100644 index 0000000..e936b9b --- /dev/null +++ b/Assets_DLL/Core/Audio/PlayAudioFile.cs @@ -0,0 +1,139 @@ +using System.Collections; +using UnityEngine; +using UnityEngine.UI; + +namespace Core.Audio +{ + public sealed class PlayAudioFile : MonoBehaviour + { + public enum SourceType + { + Flat = 0, + Surround = 1, + } + + public enum AudioFileType + { + Music = 0, + Sound = 1, + Voice = 2, + } + + public enum PlayType + { + OnStart = 0, + OnClickButton = 1, + OnClickCollider = 2, + OnPlayParticle = 3, + } + + [SerializeField] private SourceType _sourceType = SourceType.Flat; + [SerializeField] private AudioFileType _audioFileType = AudioFileType.Music; + [SerializeField] private PlayType _playType = PlayType.OnStart; + [SerializeField] private float _startDelay = 0f; + [SerializeField] private bool _loop = false; + [SerializeField] private float _minDistance = 0f; + [SerializeField] private float _maxDistance = 100f; + [SerializeField] private string[] _audioFileNames = new string[0]; + + private ParticleSystem _particleSystem = null; + private Button _button = null; + + private bool _isPlaying = false; + + private void Awake() + { + _button = GetComponent