public static void BGMStopPatch(ref int bgmIndex)
        {
            if (acac == null || acac.Count() <= 0)
            {
                return;
            }

            if (!BGMController.HasBGM(bgmIndex))
            {
                bgmIndex = 0;
            }
            try
            {
                System.Random rd    = new System.Random();
                int           rdidx = rd.Next() % acac.Count;
                if (!RandomPlay.Value)
                {
                    rdidx      = bgmplaying % acac.Count;
                    bgmplaying = (bgmplaying + 1) % acac.Count;
                }
                RootAS = BGMController.instance.musics[bgmIndex];
                RootAS.Stop();
                if (newbgmAS == null)
                {
                    newbgmAS = RootAS.gameObject.AddComponent <AudioSource>();
                }
                else if (ChangeFollowOri.Value)
                {
                    newbgmAS.Stop();
                    newbgmAS = RootAS.gameObject.AddComponent <AudioSource>();
                }
                else
                {
                    return;
                }

                newbgmAS.clip   = acac[rdidx];
                newbgmAS.volume = VFAudio.audioVolume * VFAudio.musicVolume;
                newbgmAS.Play();
                beginsec  = DateTime.Now.Ticks / 10000000;
                bgmlength = newbgmAS.clip.length;
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
 public static void BGMGetPatch(ref int bgmIndex)
 {
     if (!BGMController.HasBGM(bgmIndex))
     {
         bgmIndex = 0;
     }
     //int num = BGMController.instance.musics.Length;
     try
     {
         AudioSource audioSource = BGMController.instance.musics[bgmIndex];
         BaseAS = audioSource;
         while (ALLAS.Count < maxlen)
         {
             AudioSource nas = BaseAS.gameObject.AddComponent <AudioSource>();
             ALLAS.Add(nas);
         }
     }
     catch (Exception)
     {
     }
 }