Пример #1
0
        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();
            }
        }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }