Beispiel #1
0
        /// <summary>
        /// Copies another AudioItem.
        /// </summary>
        /// <param name="reference"> The AudioItem to copy. </param>
        public void Copy(AudioItemBase reference)
        {
            identifier      = reference.identifier;
            itemManager     = reference.itemManager;
            state           = reference.state;
            spatializer     = reference.spatializer;
            parent          = reference.parent;
            scheduledTime   = reference.scheduledTime;
            scheduleStarted = reference.scheduleStarted;
            volumeModifier.Copy(reference.volumeModifier);
            pitchModifier.Copy(reference.pitchModifier);
            rampVolumeTweener.Copy(reference.rampVolumeTweener);
            rampParentVolumeTweener.Copy(reference.rampParentVolumeTweener);
            rampPitchTweener.Copy(reference.rampPitchTweener);
            rampParentPitchTweener.Copy(reference.rampParentPitchTweener);
            fadeTweener.Copy(reference.fadeTweener);
            pausedState = reference.pausedState;
            hasFaded    = reference.hasFaded;
            hasBreak    = reference.hasBreak;
            Copier <AudioDelayedOption> .Default.CopyTo(reference.delayedOptions, delayedOptions);

            OnPlay         = reference.OnPlay;
            OnPause        = reference.OnPause;
            OnResume       = reference.OnResume;
            OnStopping     = reference.OnStopping;
            OnStop         = reference.OnStop;
            OnUpdate       = reference.OnUpdate;
            OnStateChanged = reference.OnStateChanged;
        }
        public AudioDynamicItem CreateDynamicItem(DynamicGetter getNextSettings, AudioSpatializer spatializer, IAudioItem parent)
        {
            var item = TypePoolManager.Create<AudioDynamicItem>();
            item.Initialize(getNextSettings, this, spatializer, parent);

            return item;
        }
Beispiel #3
0
        public AudioDynamicItem CreateDynamicItem(DynamicGetter getNextSettings, AudioSpatializer spatializer, IAudioItem parent)
        {
            var item = TypePoolManager.Create <AudioDynamicItem>();

            item.Initialize(getNextSettings, this, spatializer, parent);

            return(item);
        }
        public void Initialize(DynamicGetter getNextSettings, AudioItemManager itemManager, AudioSpatializer spatializer, IAudioItem parent)
        {
            settings = TypePoolManager.Create<AudioDynamicSettings>();

            base.Initialize(settings.Identifier, itemManager, spatializer, parent);

            this.getNextSettings = getNextSettings ?? delegate { return null; };

            InitializeModifiers(settings);
            InitializeSources();
        }
Beispiel #5
0
        protected void Initialize(int identifier, AudioItemManager itemManager, AudioSpatializer spatializer, IAudioItem parent)
        {
            this.identifier  = identifier;
            this.itemManager = itemManager;
            this.spatializer = spatializer;
            this.parent      = parent;

            if (this.parent == null)
            {
                itemManager.Activate(this);
            }

            SetState(AudioStates.Waiting);
        }
Beispiel #6
0
        public AudioItemBase CreateItem(AudioSettingsBase settings, AudioSpatializer spatializer, IAudioItem parent)
        {
            if (settings == null)
            {
                return(null);
            }

            switch (settings.Type)
            {
            default:
                var sourceItem = TypePoolManager.Create <AudioSourceItem>();
                var source     = PrefabPoolManager.Create(audioManager.Reference);
                source.Copy(audioManager.Reference, audioManager.UseCustomCurves);
                sourceItem.Initialize((AudioSourceSettings)settings, this, source, spatializer, parent);
                return(sourceItem);

            case AudioTypes.MixContainer:
                var mixContainerItem = TypePoolManager.Create <AudioMixContainerItem>();
                mixContainerItem.Initialize((AudioMixContainerSettings)settings, this, spatializer, parent);
                return(mixContainerItem);

            case AudioTypes.RandomContainer:
                var randomContainerItem = TypePoolManager.Create <AudioRandomContainerItem>();
                randomContainerItem.Initialize((AudioRandomContainerSettings)settings, this, spatializer, parent);
                return(randomContainerItem);

            case AudioTypes.EnumeratorContainer:
                var enumeratorContainerItem = TypePoolManager.Create <AudioEnumeratorContainerItem>();
                enumeratorContainerItem.Initialize((AudioEnumeratorContainerSettings)settings, this, spatializer, parent);
                return(enumeratorContainerItem);

            case AudioTypes.SwitchContainer:
                var switchContainerItem = TypePoolManager.Create <AudioSwitchContainerItem>();
                switchContainerItem.Initialize((AudioSwitchContainerSettings)settings, this, spatializer, parent);
                return(switchContainerItem);

            case AudioTypes.SequenceContainer:
                var sequenceContainerItem = TypePoolManager.Create <AudioSequenceContainerItem>();
                sequenceContainerItem.Initialize((AudioSequenceContainerSettings)settings, this, spatializer, parent);
                return(sequenceContainerItem);
            }
        }
Beispiel #7
0
        public void Initialize(AudioMixContainerSettings settings, AudioItemManager itemManager, AudioSpatializer spatializer, IAudioItem parent)
        {
            base.Initialize(settings.Identifier, itemManager, spatializer, parent);

            originalSettings = settings;
            this.settings    = PrefabPoolManager.Create(settings);

            InitializeModifiers(originalSettings);
            InitializeSources();

            for (int i = 0; i < originalSettings.Options.Count; i++)
            {
                ApplyOption(originalSettings.Options[i], false);
            }
        }
Beispiel #8
0
        public void Initialize(AudioSourceSettings settings, AudioItemManager itemManager, AudioSource audioSource, AudioSpatializer spatializer, IAudioItem parent)
        {
            base.Initialize(settings.Identifier, itemManager, spatializer, parent);

            // General Setup
            originalSettings        = settings;
            this.settings           = PrefabPoolManager.Create(settings);
            source                  = audioSource;
            source.transform.parent = itemManager.AudioManager.Reference.transform.parent;
            base.spatializer.AddSource(source.transform);

            // Setup the AudioSource
            source.Stop();
            source.clip = this.settings.Clip;
            source.name = settings.Name;
            source.outputAudioMixerGroup = this.settings.Output;
            source.loop         = this.settings.Loop;
            source.spatialBlend = base.spatializer.SpatializeMode == AudioSpatializer.SpatializeModes.None ? 0f : source.spatialBlend;

            InitializeModifiers(originalSettings);

            for (int i = 0; i < originalSettings.Options.Count; i++)
            {
                ApplyOption(originalSettings.Options[i], false);
            }

            if (this.settings.MaxInstances > 0)
            {
                itemManager.TrimInstances(this, this.settings.MaxInstances);
            }
        }
        public AudioItemBase CreateItem(AudioSettingsBase settings, AudioSpatializer spatializer, IAudioItem parent)
        {
            if (settings == null)
                return null;

            switch (settings.Type)
            {
                default:
                    var sourceItem = TypePoolManager.Create<AudioSourceItem>();
                    var source = PrefabPoolManager.Create(audioManager.Reference);
                    source.Copy(audioManager.Reference, audioManager.UseCustomCurves);
                    sourceItem.Initialize((AudioSourceSettings)settings, this, source, spatializer, parent);
                    return sourceItem;
                case AudioTypes.MixContainer:
                    var mixContainerItem = TypePoolManager.Create<AudioMixContainerItem>();
                    mixContainerItem.Initialize((AudioMixContainerSettings)settings, this, spatializer, parent);
                    return mixContainerItem;
                case AudioTypes.RandomContainer:
                    var randomContainerItem = TypePoolManager.Create<AudioRandomContainerItem>();
                    randomContainerItem.Initialize((AudioRandomContainerSettings)settings, this, spatializer, parent);
                    return randomContainerItem;
                case AudioTypes.EnumeratorContainer:
                    var enumeratorContainerItem = TypePoolManager.Create<AudioEnumeratorContainerItem>();
                    enumeratorContainerItem.Initialize((AudioEnumeratorContainerSettings)settings, this, spatializer, parent);
                    return enumeratorContainerItem;
                case AudioTypes.SwitchContainer:
                    var switchContainerItem = TypePoolManager.Create<AudioSwitchContainerItem>();
                    switchContainerItem.Initialize((AudioSwitchContainerSettings)settings, this, spatializer, parent);
                    return switchContainerItem;
                case AudioTypes.SequenceContainer:
                    var sequenceContainerItem = TypePoolManager.Create<AudioSequenceContainerItem>();
                    sequenceContainerItem.Initialize((AudioSequenceContainerSettings)settings, this, spatializer, parent);
                    return sequenceContainerItem;
            }
        }