예제 #1
0
 // Token: 0x06000189 RID: 393 RVA: 0x000186B4 File Offset: 0x000168B4
 public void PlaySFXCloseBGM(ushort NameID, float delay = 0f, PitchKind pitchkind = PitchKind.NoPitch, Transform PlayObj = null)
 {
     if (this.MuteSFXVol)
     {
         return;
     }
     this.AddCloseQueue(100);
     this.PlaySFX(NameID, delay, pitchkind, PlayObj, null);
     if (this.poolIndex == 0)
     {
         this.poolIndex = 19;
     }
     this.CurUseIndex = this.poolIndex - 1;
     this.PauseSFX(this.CurUseIndex);
 }
예제 #2
0
    // Token: 0x0600018A RID: 394 RVA: 0x00018718 File Offset: 0x00016918
    public void PlaySFX(ushort NameID, float delay = 0f, PitchKind pitchkind = PitchKind.NoPitch, Transform PlayObj = null, Vector3?Position = null)
    {
        if (this.MuteSFXVol || NameID == 0)
        {
            return;
        }
        int num = (int)(NameID / 100);

        if (num == 37 || num == 77)
        {
            PlayObj = null;
        }
        this.GetEmptyIndex();
        CString cstring = StringManager.Instance.StaticString1024();

        cstring.StringToFormat(this.Path);
        cstring.IntToFormat((long)num, 3, true);
        cstring.AppendFormat("{0}{1}");
        AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.SFXBundleKey[(int)this.poolIndex]);

        if (assetBundle)
        {
            cstring.ClearString();
            cstring.IntToFormat((long)NameID, 1, false);
            cstring.AppendFormat("{0}");
            this.SFXClip.clip = (assetBundle.Load(cstring.ToString(), typeof(AudioClip)) as AudioClip);
            if (this.SFXClip.clip == null)
            {
                AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true);
                this.SFXBundleKey[(int)this.poolIndex] = 0;
                return;
            }
            this.SFXClip.DelaySecond = new float?(delay);
            if (pitchkind != PitchKind.SpeechSound)
            {
                if (pitchkind != PitchKind.Hit)
                {
                    this.SFXClip.Pitch = 1f;
                }
                else
                {
                    this.SFXClip.Pitch = 0.8909f + 0.2316f * UnityEngine.Random.value;
                }
            }
            else
            {
                byte b = (byte)Mathf.Max(0f, 30f * UnityEngine.Random.value / 10f);
                if (b == this.SpeechSoundPrev)
                {
                    b += 1;
                    if (b >= 3)
                    {
                        b = 0;
                    }
                }
                this.SpeechSoundPrev = b;
                this.SFXClip.Pitch   = this.SpeechSoundPitchVal[(int)this.SpeechSoundPrev];
            }
            if (PlayObj != null)
            {
                this.AttachAudioSound(this.poolIndex, PlayObj);
                this.SFXClip.PanLevel = 1f;
            }
            else if (Position != null)
            {
                this.AttachAudioSound(this.poolIndex, Position.Value);
                this.SFXClip.PanLevel = 1f;
            }
            else
            {
                this.SFXClip.PanLevel = 0f;
            }
            this.SFXClip.Volume = 1f;
            this.SFXClip.Loop   = false;
            AudioSource[] sfxsource = this.SFXSource;
            byte          b2;
            this.poolIndex = (b2 = this.poolIndex) + 1;
            this.PlayAudio(sfxsource[(int)b2], this.SFXClip);
            this.ChangeDuckingState(AudioManager.DuckingState.Start);
            if (this.poolIndex >= 20)
            {
                this.poolIndex = 0;
            }
        }
        else
        {
            if (this.SFXSource[(int)this.poolIndex] == null)
            {
                Debug.LogWarning(string.Format("bundle_AbName({0}Null)", NameID));
            }
            AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true);
            this.SFXBundleKey[(int)this.poolIndex] = 0;
        }
    }