Esempio n. 1
0
        void Start()
        {
            if (SoundMaterial == null || SoundMaterial.AudioSets.Count == 0)
            {
                return;
            }

            if (AutoCreateSources)
            {
                if (!ImpactAudio.isActiveAndEnabled)
                {
                    ImpactAudio = getAudioCopy(ImpactAudio, gameObject);
                }

                baseImpactVol   = ImpactAudio.volume;
                baseImpactPitch = ImpactAudio.pitch;

                audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();
                AudioContainers    = new List <PhysSoundAudioContainer>();

                foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets)
                {
                    PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key);
                    audCont.SlideAudio = getAudioCopy(ImpactAudio, this.gameObject);

                    audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide);
                    audioContainersDic.Add(audCont.KeyIndex, audCont);
                    AudioContainers.Add(audCont);
                }

                ImpactAudio.loop = false;
            }
            else
            {
                if (ImpactAudio)
                {
                    ImpactAudio.loop = false;
                    baseImpactVol    = ImpactAudio.volume;
                    baseImpactPitch  = ImpactAudio.pitch;
                }

                if (AudioContainers.Count > 0)
                {
                    audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();

                    foreach (PhysSoundAudioContainer audCont in AudioContainers)
                    {
                        if (!SoundMaterial.HasAudioSet(audCont.KeyIndex))
                        {
                            Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list.");
                            continue;
                        }

                        audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide);
                        audioContainersDic.Add(audCont.KeyIndex, audCont);
                    }
                }
            }
        }
Esempio n. 2
0
        void Start()
        {
            if (SoundMaterial == null || SoundMaterial.AudioSets.Count == 0)
                return;

            if (AutoCreateSources)
            {
                if (!ImpactAudio.isActiveAndEnabled)
                {
                    ImpactAudio = getAudioCopy(ImpactAudio, gameObject);
                }

                baseImpactVol = ImpactAudio.volume;
                baseImpactPitch = ImpactAudio.pitch;

                audioContainersDic = new Dictionary<int, PhysSoundAudioContainer>();
                AudioContainers = new List<PhysSoundAudioContainer>();

                foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets)
                {
                    PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key);
                    audCont.SlideAudio = getAudioCopy(ImpactAudio, this.gameObject);

                    audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide);
                    audioContainersDic.Add(audCont.KeyIndex, audCont);
                    AudioContainers.Add(audCont);
                }

                ImpactAudio.loop = false;
            }
            else
            {
                if (ImpactAudio)
                {
                    ImpactAudio.loop = false;
                    baseImpactVol = ImpactAudio.volume;
                    baseImpactPitch = ImpactAudio.pitch;
                }

                if (AudioContainers.Count > 0)
                {
                    audioContainersDic = new Dictionary<int, PhysSoundAudioContainer>();

                    foreach (PhysSoundAudioContainer audCont in AudioContainers)
                    {
                        if (!SoundMaterial.HasAudioSet(audCont.KeyIndex))
                        {
                            Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list.");
                            continue;
                        }

                        audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide);
                        audioContainersDic.Add(audCont.KeyIndex, audCont);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the PhysSoundObject. Use this if you adding a PhysSoundObject component to an object at runtime.
        /// </summary>
        public override void Initialize()
        {
            _r   = GetComponent <Rigidbody>();
            _r2D = GetComponent <Rigidbody2D>();

            if (AutoCreateSources)
            {
                baseImpactVol   = ImpactAudio.volume;
                baseImpactPitch = ImpactAudio.pitch;

                _audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();
                AudioContainers     = new List <PhysSoundAudioContainer>();

                foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets)
                {
                    if (audSet.Slide == null)
                    {
                        continue;
                    }

                    PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key);
                    audCont.SlideAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(ImpactAudio, this.gameObject);

                    audCont.Initialize(this);
                    _audioContainersDic.Add(audCont.KeyIndex, audCont);
                    AudioContainers.Add(audCont);
                }

                ImpactAudio.loop = false;
            }
            else
            {
                if (ImpactAudio)
                {
                    ImpactAudio.loop = false;
                    baseImpactVol    = ImpactAudio.volume;
                    baseImpactPitch  = ImpactAudio.pitch;
                }

                if (AudioContainers.Count > 0)
                {
                    _audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();

                    foreach (PhysSoundAudioContainer audCont in AudioContainers)
                    {
                        if (!SoundMaterial.HasAudioSet(audCont.KeyIndex))
                        {
                            Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list.");
                            continue;
                        }

                        if (PlayClipAtPoint)
                        {
                            audCont.Initialize(this, ImpactAudio);
                        }
                        else
                        {
                            audCont.Initialize(this);
                        }

                        _audioContainersDic.Add(audCont.KeyIndex, audCont);
                    }
                }
            }

            if (PlayClipAtPoint)
            {
                PhysSoundTempAudioPool.Create();
            }
            else if (ImpactAudio != null && !ImpactAudio.isActiveAndEnabled)
            {
                ImpactAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(ImpactAudio, gameObject);
            }
        }
Esempio n. 4
0
 // Token: 0x06003FD5 RID: 16341 RVA: 0x0014098C File Offset: 0x0013ED8C
 private void Start()
 {
     if (this.SoundMaterial == null)
     {
         return;
     }
     this.r   = base.GetComponent <Rigidbody>();
     this.r2D = base.GetComponent <Rigidbody2D>();
     if (this.AutoCreateSources)
     {
         if (!this.ImpactAudio.isActiveAndEnabled && !this.PlayClipAtPoint)
         {
             this.ImpactAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(this.ImpactAudio, base.gameObject);
         }
         this.baseImpactVol      = this.ImpactAudio.volume;
         this.baseImpactPitch    = this.ImpactAudio.pitch;
         this.audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();
         this.AudioContainers    = new List <PhysSoundAudioContainer>();
         foreach (PhysSoundAudioSet physSoundAudioSet in this.SoundMaterial.AudioSets)
         {
             if (!(physSoundAudioSet.Slide == null))
             {
                 PhysSoundAudioContainer physSoundAudioContainer = new PhysSoundAudioContainer(physSoundAudioSet.Key);
                 physSoundAudioContainer.SlideAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(this.ImpactAudio, base.gameObject);
                 physSoundAudioContainer.Initialize(this.SoundMaterial);
                 this.audioContainersDic.Add(physSoundAudioContainer.KeyIndex, physSoundAudioContainer);
                 this.AudioContainers.Add(physSoundAudioContainer);
             }
         }
         this.ImpactAudio.loop = false;
     }
     else
     {
         if (this.ImpactAudio)
         {
             this.ImpactAudio.loop = false;
             this.baseImpactVol    = this.ImpactAudio.volume;
             this.baseImpactPitch  = this.ImpactAudio.pitch;
         }
         if (this.AudioContainers.Count > 0)
         {
             this.audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>();
             foreach (PhysSoundAudioContainer physSoundAudioContainer2 in this.AudioContainers)
             {
                 if (!this.SoundMaterial.HasAudioSet(physSoundAudioContainer2.KeyIndex))
                 {
                     Debug.LogError("PhysSound Object " + base.gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list.");
                 }
                 else
                 {
                     physSoundAudioContainer2.Initialize(this.SoundMaterial);
                     this.audioContainersDic.Add(physSoundAudioContainer2.KeyIndex, physSoundAudioContainer2);
                 }
             }
         }
     }
     if (this.PlayClipAtPoint)
     {
         PhysSoundTempAudioPool.Create();
     }
 }