public void Initialize(PhysSoundTempAudioPool pool)
        {
            Audio = gameObject.AddComponent <AudioSource>();

            transform.SetParent(pool.transform);
            gameObject.SetActive(false);
        }
예제 #2
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;

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

            if (PlayClipAtPoint)
            {
                PhysSoundTempAudioPool.Create();
            }
            else if (ImpactAudio != null && !ImpactAudio.isActiveAndEnabled)
            {
                ImpactAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(ImpactAudio, gameObject);
            }
        }
예제 #3
0
 // Token: 0x06003FF1 RID: 16369 RVA: 0x001419A4 File Offset: 0x0013FDA4
 public void PlayClip(AudioClip clip, Vector3 point, AudioSource template, float volume, float pitch)
 {
     PhysSoundTempAudioPool.GetAudioSourceCopy(template, this.audioSource);
     base.transform.position = point;
     this.audioSource.clip   = clip;
     this.audioSource.volume = volume;
     this.audioSource.pitch  = pitch;
     base.gameObject.SetActive(true);
     this.audioSource.Play();
 }
예제 #4
0
        // Token: 0x06003FF7 RID: 16375 RVA: 0x00141AF4 File Offset: 0x0013FEF4
        public static AudioSource GetAudioSourceCopy(AudioSource template, GameObject g)
        {
            AudioSource audioSource = g.AddComponent <AudioSource>();

            if (!template)
            {
                return(audioSource);
            }
            PhysSoundTempAudioPool.GetAudioSourceCopy(template, audioSource);
            return(audioSource);
        }
예제 #5
0
        // Token: 0x06003FF6 RID: 16374 RVA: 0x00141ABC File Offset: 0x0013FEBC
        public static void Create()
        {
            if (PhysSoundTempAudioPool.Instance != null)
            {
                return;
            }
            GameObject             gameObject             = new GameObject("PhysSound Temp Audio Pool");
            PhysSoundTempAudioPool physSoundTempAudioPool = gameObject.AddComponent <PhysSoundTempAudioPool>();

            physSoundTempAudioPool.Initialize();
        }
        public void PlayClip(AudioClip clip, Vector3 point, AudioSource template, float volume, float pitch)
        {
            PhysSoundTempAudioPool.CopyAudioSource(template, Audio);

            transform.position = point;

            Audio.clip   = clip;
            Audio.volume = volume;
            Audio.pitch  = pitch;

            gameObject.SetActive(true);

            Audio.Play();
        }
        public void Initialize()
        {
            Instance = this;

            audioSources = new PhysSoundTempAudio[TempAudioPoolSize];

            for (int i = 0; i < TempAudioPoolSize; i++)
            {
                GameObject         g = new GameObject("Temp Audio Source");
                PhysSoundTempAudio a = g.AddComponent <PhysSoundTempAudio>();
                a.Initialize(this);

                audioSources[i] = a;
            }
        }
예제 #8
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);
            }
        }
예제 #9
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();
     }
 }