internal SFXPlayer(AudioClipsStorer clipsStorer) { var updater = SharedServices.GetService <IUpdateScheduler>(); if (updater == null) { updater = new UnityUpdateScheduler(); SharedServices.RegisterService(updater); } var dispatcher = SharedServices.GetService <EventDispatcher>(); if (dispatcher == null) { dispatcher = new EventDispatcher(); SharedServices.RegisterService(dispatcher); } updater.ScheduleUpdate(this); dispatcher.AddListener <SceneManagementService.SceneUnloadedEvent>(OnSceneUnloaded); _clipStorer = clipsStorer; for (int i = 0; i < 10; ++i) { CreateHandler(); } }
public AudioService(AudioClipsStorer storer, float volume = 1f, float sfxVolume = 1f, float musicVolume = 1f) { _sfxPlayer = new SFXPlayer(storer); _musicPlayer = new MusicPlayer(storer); Volume = volume; SFXVolume = sfxVolume; MusicVolume = musicVolume; }
internal MusicPlayer(AudioClipsStorer clipStorer) { if (!SharedServices.HasService <ICoroutineRunner>()) { SharedServices.RegisterService <ICoroutineRunner>(new CoroutineRunner()); } _clipStorer = clipStorer; _source = new GameObject("MusicPlayer").AddComponent <AudioSource>(); UnityEngine.Object.DontDestroyOnLoad(_source.gameObject); _source.playOnAwake = false; _source.spatialBlend = 0f; }