Browse Source

- Реклама в лабі

Seraph 4 years ago
parent
commit
391f463a3a
  1. 6
      Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs
  2. 9
      Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs
  3. 19
      Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs
  4. 2
      Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs
  5. 10
      Assets_DLL/Core/Audio/AudioController.cs
  6. 39
      Assets_DLL/Core/Audio/AudioController2D.cs
  7. 6
      Assets_DLL/Core/Audio/AudioController3D.cs
  8. 4
      Assets_DLL/Core/Audio/PlayAudioFile.cs
  9. 3
      Assets_DLL/Core/SceneManagement/SceneLoader.cs
  10. BIN
      Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll
  11. BIN
      Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache
  12. 0
      Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.CopyComplete

6
Assets_DLL/Core/Ads/BridgeInterfaces/IBannerBridge.cs

@ -1,11 +1,9 @@
using UnityEngine; namespace Core.Ads.BridgeInterfaces
namespace Core.Ads.BridgeInterfaces
{ {
public interface IBannerBridge public interface IBannerBridge
{ {
bool IsVisible();
void Show(BannerPositions position); void Show(BannerPositions position);
void Hide(); void Hide();
bool IsVisible();
} }
} }

9
Assets_DLL/Core/Ads/BridgeInterfaces/IInterstitialBridge.cs

@ -1,11 +1,10 @@
using System; namespace Core.Ads.BridgeInterfaces
using UnityEngine;
namespace Core.Ads.BridgeInterfaces
{ {
public delegate void OnInterstitialEnded();
public interface IInterstitialBridge public interface IInterstitialBridge
{ {
Action OnEnded { get; set; } event OnInterstitialEnded OnEnded;
bool IsReady(); bool IsReady();
void Show(); void Show();
bool IsVisible(); bool IsVisible();

19
Assets_DLL/Core/Ads/Bridges/DemoAds/DemoBannerAds.cs

@ -42,22 +42,11 @@ namespace Core.Ads.Bridges.DemoAds
private Vector2 CalculateBannerSize() 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)) return new Vector2(bannerSize * 6.4f, bannerSize);
{
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);
} }
private Vector2 CalculateBannerPosition(Vector2 bannerSize) private Vector2 CalculateBannerPosition(Vector2 bannerSize)
{ {

2
Assets_DLL/Core/Ads/Bridges/DemoAds/DemoInterstitialAds.cs

@ -8,7 +8,7 @@ namespace Core.Ads.Bridges.DemoAds
{ {
public sealed class DemoInterstitialAds : MonoBehaviour, IInterstitialBridge public sealed class DemoInterstitialAds : MonoBehaviour, IInterstitialBridge
{ {
public Action OnEnded { get; set; } public event OnInterstitialEnded OnEnded = null;
private bool _isInterstitialReady = false; private bool _isInterstitialReady = false;

10
Assets_DLL/Core/Audio/AudioController.cs

@ -9,6 +9,8 @@ namespace Core.Audio
{ {
public class AudioController : MonoBehaviour public class AudioController : MonoBehaviour
{ {
private static AudioController _controller = null;
private static AudioController2D _audio2D = null; private static AudioController2D _audio2D = null;
private static AudioController3D _audio3D = null; private static AudioController3D _audio3D = null;
@ -16,7 +18,7 @@ namespace Core.Audio
{ {
GameObject audioParent = new GameObject("[AudioController]"); GameObject audioParent = new GameObject("[AudioController]");
audioParent.AddComponent<AudioController>(); _controller = audioParent.AddComponent<AudioController>();
GameObject.DontDestroyOnLoad(audioParent); GameObject.DontDestroyOnLoad(audioParent);
@ -83,11 +85,11 @@ namespace Core.Audio
} }
} }
public static float PlayMusic(string name, bool isLoop = false) => public static void PlayMusic(string name) =>
_audio2D.PlayMusic(name, isLoop); _controller.StartCoroutine(_audio2D.PlayMusic(name));
public static void StopMusic() => public static void StopMusic() =>
_audio2D.StopMusic(); _controller.StartCoroutine(_audio2D.StopMusic());
public static float PlaySound(string name, bool isLoop = false) => public static float PlaySound(string name, bool isLoop = false) =>
_audio2D.PlaySound(name, isLoop); _audio2D.PlaySound(name, isLoop);

39
Assets_DLL/Core/Audio/AudioController2D.cs

@ -5,6 +5,7 @@ using UnityEngine;
using Core.Settings; using Core.Settings;
using Core.Tools.Saves; using Core.Tools.Saves;
using System; using System;
using System.Collections;
namespace Core.Audio 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) if (_musicSource == null)
{ {
@ -74,23 +75,49 @@ namespace Core.Audio
_musicSource.volume = CoreSettings.data.musicVolume * MusicVolume; _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)) if (_musicAndSounds.ContainsKey(name))
{ {
_musicSource.clip = _musicAndSounds[name]; _musicSource.clip = _musicAndSounds[name];
_musicSource.loop = isLoop; _musicSource.loop = true;
_musicSource.gameObject.SetActive(true); _musicSource.gameObject.SetActive(true);
_musicSource.enabled = true;
_musicSource.Play(); _musicSource.Play();
return _musicAndSounds[name].length; while (_musicSource.volume < MusicVolume)
{
yield return null;
_musicSource.volume += Time.deltaTime / 2f;
}
_musicSource.volume = MusicVolume;
} }
else else
throw new ArgumentNullException($"music \"{name}\" not found"); 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.Stop();
_musicSource.volume = MusicVolume;
} }
internal float PlaySound(string name, bool isLoop = false) internal float PlaySound(string name, bool isLoop = false)
@ -112,6 +139,8 @@ namespace Core.Audio
playSource.loop = isLoop; playSource.loop = isLoop;
playSource.gameObject.SetActive(true); playSource.gameObject.SetActive(true);
playSource.enabled = true;
playSource.Play(); playSource.Play();
return _musicAndSounds[name].length; return _musicAndSounds[name].length;
@ -149,6 +178,8 @@ namespace Core.Audio
playSource.clip = _voicesDictionary[LocalizationManager.CurrentLanguage][name]; playSource.clip = _voicesDictionary[LocalizationManager.CurrentLanguage][name];
playSource.gameObject.SetActive(true); playSource.gameObject.SetActive(true);
playSource.enabled = true;
playSource.Play(); playSource.Play();
return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length; return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length;

6
Assets_DLL/Core/Audio/AudioController3D.cs

@ -52,6 +52,8 @@ namespace Core.Audio
{ {
AudioSource playSource = _soundsSources.Where(s => s != null && !s.isPlaying).FirstOrDefault(); AudioSource playSource = _soundsSources.Where(s => s != null && !s.isPlaying).FirstOrDefault();
Debug.LogError($"enable: {playSource.enabled}, active: {playSource.gameObject.activeSelf}");
if (playSource == null) if (playSource == null)
{ {
GameObject sound = new GameObject("Sound"); GameObject sound = new GameObject("Sound");
@ -78,6 +80,8 @@ namespace Core.Audio
playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f));
playSource.gameObject.SetActive(true); playSource.gameObject.SetActive(true);
playSource.enabled = true;
playSource.Play(); playSource.Play();
return _musicAndSounds[name].length; return _musicAndSounds[name].length;
@ -126,6 +130,8 @@ namespace Core.Audio
playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f)); playSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, AnimationCurve.Linear(0f, 1f, 1f, 0f));
playSource.gameObject.SetActive(true); playSource.gameObject.SetActive(true);
playSource.enabled = true;
playSource.Play(); playSource.Play();
return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length; return _voicesDictionary[LocalizationManager.CurrentLanguage][name].length;

4
Assets_DLL/Core/Audio/PlayAudioFile.cs

@ -118,8 +118,8 @@ namespace Core.Audio
{ {
case AudioFileType.Music: case AudioFileType.Music:
time = AudioController.PlayMusic(_audioFileNames[Random.Range(0, _audioFileNames.Length)], _loop); AudioController.PlayMusic(_audioFileNames[Random.Range(0, _audioFileNames.Length)]);
break; yield break;
case AudioFileType.Sound: case AudioFileType.Sound:

3
Assets_DLL/Core/SceneManagement/SceneLoader.cs

@ -5,6 +5,7 @@ using UnityEngine.SceneManagement;
using Core.Settings; using Core.Settings;
using Core.Ads; using Core.Ads;
using System.Linq; using System.Linq;
using Core.Tools.Saves;
namespace Core.SceneManagement namespace Core.SceneManagement
{ {
@ -58,6 +59,8 @@ namespace Core.SceneManagement
OnLoadedStart?.Invoke(scene); OnLoadedStart?.Invoke(scene);
_current.StartCoroutine(StartLoad(scene)); _current.StartCoroutine(StartLoad(scene));
SaveManager.Save();
} }
private static IEnumerator StartLoad(string scene) private static IEnumerator StartLoad(string scene)

BIN
Assets_DLL/Core/obj/Debug/netstandard2.0/Core.dll

Binary file not shown.

BIN
Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.AssemblyReference.cache

Binary file not shown.

0
Assets_DLL/CoreEditor/obj/Debug/netstandard2.0/CoreEditor.csproj.CopyComplete

Loading…
Cancel
Save