SoundMgr.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Xml.Linq;
  5. using UnityEngine;
  6. using wf;
  7. public class SoundMgr : MonoBehaviour
  8. {
  9. public AudioSourceMgr m_AudioDummyVoice { get; private set; }
  10. public AudioMixerMgr mix_mgr { get; private set; }
  11. public static float ConvertToAudioSourcePitch(int pitch)
  12. {
  13. return 1f + (0.3f * ((float)pitch * 0.01f) - 0.15f);
  14. }
  15. public int GetVolumeAll()
  16. {
  17. return this.m_nAllVol;
  18. }
  19. public void SetVolumeAll(int f_nVol)
  20. {
  21. this.m_nAllVol = System.Math.Min(System.Math.Max(0, f_nVol), 100);
  22. }
  23. public int GetVolume(AudioSourceMgr.Type f_eType)
  24. {
  25. return this.m_nVol[(int)f_eType];
  26. }
  27. public int GetVolumeDance()
  28. {
  29. return this.m_nDanceVol;
  30. }
  31. public void SetVolume(AudioSourceMgr.Type f_eType, int f_nVol)
  32. {
  33. this.m_nVol[(int)f_eType] = f_nVol;
  34. }
  35. public void SetVolumeDance(int f_nVol)
  36. {
  37. this.m_nDanceVol = f_nVol;
  38. }
  39. public bool GetThreeD(AudioSourceMgr.Type f_eType)
  40. {
  41. return this.m_bThreeD[(int)f_eType];
  42. }
  43. public void SetThreeD(AudioSourceMgr.Type f_eType, bool f_bEnable)
  44. {
  45. this.m_bThreeD[(int)f_eType] = f_bEnable;
  46. }
  47. public void Init(GameObject f_goParent)
  48. {
  49. this.m_goAudioMgr = UTY.GetChildObject(GameMain.Instance.MainCamera.gameObject, "AudioMgr", false);
  50. this.mix_mgr = Utility.CreatePrefab(this.m_goAudioMgr.gameObject, "System/AudioMixerMgr", true).GetComponent<AudioMixerMgr>();
  51. this.m_AudioFadeBufBgm = new SoundMgr.AudioFadeBuffer(AudioSourceMgr.Type.Bgm, "AudioBgm", 2, true, this, this.m_goAudioMgr);
  52. this.m_AudioFadeBufEnv = new SoundMgr.AudioFadeBuffer(AudioSourceMgr.Type.Env, "AudioEnv", 2, true, this, this.m_goAudioMgr);
  53. this.m_AudioSeBufSe = new SoundMgr.AudioMultiBuffer(AudioSourceMgr.Type.Se, "AudioSe", 12, true, this, this.m_goAudioMgr);
  54. this.m_trAudioSystem = new GameObject("AudioSet-System-AudioSystem").transform;
  55. this.m_trAudioSystem.SetParent(this.m_goAudioMgr.transform, false);
  56. this.m_AudioDummyVoice = this.AllocVoice(this.m_goAudioMgr.transform, true);
  57. this.SetVolumeAll(80);
  58. this.SetVolume(AudioSourceMgr.Type.Bgm, 35);
  59. this.SetVolume(AudioSourceMgr.Type.Se, 60);
  60. this.SetVolume(AudioSourceMgr.Type.System, 50);
  61. this.SetVolume(AudioSourceMgr.Type.Env, 50);
  62. this.SetVolume(AudioSourceMgr.Type.Voice, 80);
  63. this.SetVolume(AudioSourceMgr.Type.VoiceHeroine, 100);
  64. this.SetVolume(AudioSourceMgr.Type.VoiceSub, 100);
  65. this.SetVolume(AudioSourceMgr.Type.VoiceExtra, 100);
  66. this.SetVolume(AudioSourceMgr.Type.VoiceMob, 100);
  67. this.SetVolumeDance(70);
  68. this.SetThreeD(AudioSourceMgr.Type.Bgm, false);
  69. this.SetThreeD(AudioSourceMgr.Type.Se, true);
  70. this.SetThreeD(AudioSourceMgr.Type.Env, true);
  71. this.SetThreeD(AudioSourceMgr.Type.Voice, false);
  72. this.SetThreeD(AudioSourceMgr.Type.VoiceHeroine, true);
  73. this.SetThreeD(AudioSourceMgr.Type.VoiceSub, true);
  74. this.SetThreeD(AudioSourceMgr.Type.VoiceExtra, true);
  75. this.SetThreeD(AudioSourceMgr.Type.VoiceMob, true);
  76. }
  77. public void PlayBGM(string f_strFileName, float f_fTime, bool f_fLoop = true)
  78. {
  79. this.m_AudioFadeBufBgm.Play(f_strFileName, f_fTime, true, f_fLoop, null);
  80. }
  81. public void PlayBGMLegacy(string f_strFileName, float f_fTime, bool f_fLoop = true)
  82. {
  83. bool flag = this.compatibilityMode;
  84. this.compatibilityMode = true;
  85. this.m_AudioFadeBufBgm.Play(f_strFileName, f_fTime, true, f_fLoop, null);
  86. this.compatibilityMode = flag;
  87. }
  88. public void PlayDanceBGM(string f_strFileName, float f_fTime, bool f_fLoop = true)
  89. {
  90. this.m_AudioFadeBufBgm.PlayEx(f_strFileName, f_fTime, true, f_fLoop, null, true);
  91. }
  92. public AudioSource GetAudioSourceBgm()
  93. {
  94. return this.m_AudioFadeBufBgm.GetActiveAudioSource();
  95. }
  96. public void StopBGM(float f_fTime)
  97. {
  98. this.m_AudioFadeBufBgm.Stop(f_fTime);
  99. }
  100. public void PlayEnv(string f_strFileName, float f_fTime)
  101. {
  102. this.m_AudioFadeBufEnv.Play(f_strFileName, f_fTime, true, true, null);
  103. }
  104. public void StopEnv(float f_fTime)
  105. {
  106. this.m_AudioFadeBufEnv.Stop(f_fTime);
  107. }
  108. public void PlaySe(string f_strFileName, bool f_bLoop)
  109. {
  110. this.m_AudioSeBufSe.Play(f_strFileName, 0f, false, f_bLoop, null);
  111. }
  112. public void StopSe()
  113. {
  114. this.m_AudioSeBufSe.Stop(0f);
  115. }
  116. public void StopSe(string f_strFileName)
  117. {
  118. this.m_AudioSeBufSe.Stop(0f, f_strFileName);
  119. }
  120. public void PlaySystem(string f_strFileName)
  121. {
  122. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(f_strFileName.ToLower());
  123. AudioSourceMgr audioSourceMgr;
  124. if (!this.m_dicAudioSystem.TryGetValue(fileNameWithoutExtension, out audioSourceMgr))
  125. {
  126. GameObject original = Resources.Load("System/Prefab/AudioSystem") as GameObject;
  127. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  128. audioSourceMgr = gameObject.GetComponentsInChildren<AudioSourceMgr>(true)[0];
  129. audioSourceMgr.Init(AudioSourceMgr.Type.System, false, this, this.m_trAudioSystem.transform);
  130. audioSourceMgr.LoadFromWf(GameUty.FileSystem, f_strFileName, false);
  131. this.m_dicAudioSystem.Add(fileNameWithoutExtension, audioSourceMgr);
  132. }
  133. audioSourceMgr.PlayOneShot();
  134. }
  135. public void PlayDummyVoice(string f_strFileName, float f_fFadeTime = 0f, bool f_bStreaming = false, bool f_bLoop = false, int voice_pitch = 50, AudioSourceMgr.Type soundType = AudioSourceMgr.Type.Voice)
  136. {
  137. this.m_AudioDummyVoice.Pitch = SoundMgr.ConvertToAudioSourcePitch(voice_pitch);
  138. this.m_AudioDummyVoice.audiosource.outputAudioMixerGroup = this.mix_mgr[soundType];
  139. this.m_AudioDummyVoice.LoadPlay(f_strFileName, f_fFadeTime, f_bStreaming, f_bLoop);
  140. }
  141. public void StopDummyVoide()
  142. {
  143. this.m_AudioDummyVoice.Stop();
  144. }
  145. public bool IsPlayDummyVoice()
  146. {
  147. return this.m_AudioDummyVoice.isPlay();
  148. }
  149. public void PlaySystem(SoundMgr.SeType f_eSe)
  150. {
  151. if (f_eSe != SoundMgr.SeType.Non && f_eSe != SoundMgr.SeType.Self)
  152. {
  153. this.PlaySystem(this.m_arySeFileName[(int)f_eSe]);
  154. }
  155. }
  156. public void StopSystem()
  157. {
  158. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  159. {
  160. keyValuePair.Value.Stop();
  161. }
  162. }
  163. public AudioSourceMgr AllocVoice(Transform f_trParent, bool f_bThreeD = true)
  164. {
  165. GameObject original = Resources.Load("System/Prefab/AudioVoice") as GameObject;
  166. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  167. AudioSourceMgr audioSourceMgr = gameObject.GetComponentsInChildren<AudioSourceMgr>(true)[0];
  168. audioSourceMgr.Init(AudioSourceMgr.Type.Voice, f_bThreeD, this, f_trParent);
  169. this.m_listAudioManChara.Add(audioSourceMgr);
  170. return audioSourceMgr;
  171. }
  172. public void FreeVoice(AudioSourceMgr f_gcAudioMan, bool f_bDestoryMe)
  173. {
  174. this.m_listAudioManChara.Remove(f_gcAudioMan);
  175. f_gcAudioMan.Clear();
  176. if (f_bDestoryMe)
  177. {
  178. UnityEngine.Object.Destroy(f_gcAudioMan);
  179. }
  180. f_gcAudioMan = null;
  181. }
  182. public void StopAll()
  183. {
  184. this.VoiceStopAll();
  185. this.StopBGM(0f);
  186. this.StopEnv(0f);
  187. this.StopSe();
  188. this.StopSystem();
  189. }
  190. public void OnDestroy()
  191. {
  192. this.ClearAll();
  193. this.m_AudioFadeBufBgm = null;
  194. this.m_AudioFadeBufEnv = null;
  195. this.m_AudioSeBufSe = null;
  196. this.m_dicAudioSystem.Clear();
  197. this.m_listAudioManChara.Clear();
  198. this.m_AudioDummyVoice = null;
  199. }
  200. public void ClearAll()
  201. {
  202. if (this.m_AudioFadeBufBgm != null)
  203. {
  204. this.m_AudioFadeBufBgm.Clear();
  205. }
  206. if (this.m_AudioFadeBufEnv != null)
  207. {
  208. this.m_AudioFadeBufEnv.Clear();
  209. }
  210. if (this.m_AudioSeBufSe != null)
  211. {
  212. this.m_AudioSeBufSe.Clear();
  213. }
  214. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  215. {
  216. keyValuePair.Value.Clear();
  217. }
  218. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  219. {
  220. this.m_listAudioManChara[i].Clear();
  221. }
  222. if (this.m_AudioDummyVoice != null)
  223. {
  224. this.m_AudioDummyVoice.Clear();
  225. }
  226. }
  227. public bool isVoicePlaying()
  228. {
  229. bool flag = false;
  230. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  231. {
  232. flag |= this.m_listAudioManChara[i].isPlay();
  233. }
  234. return flag | this.m_AudioDummyVoice.isPlay();
  235. }
  236. public void VoiceStopAll()
  237. {
  238. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  239. {
  240. this.m_listAudioManChara[i].Stop();
  241. }
  242. this.m_AudioDummyVoice.Stop();
  243. }
  244. public void Apply()
  245. {
  246. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Master, (float)this.m_nAllVol * 0.01f);
  247. this.mix_mgr.SetVolume(AudioMixerMgr.Group.BGM, (float)this.GetVolume(AudioSourceMgr.Type.Bgm) * 0.01f);
  248. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Voice, (float)this.GetVolume(AudioSourceMgr.Type.Voice) * 0.01f);
  249. this.mix_mgr.SetVolume(AudioMixerMgr.Group.VoiceHeroine, (float)this.GetVolume(AudioSourceMgr.Type.VoiceHeroine) * 0.01f);
  250. this.mix_mgr.SetVolume(AudioMixerMgr.Group.VoiceSub, (float)this.GetVolume(AudioSourceMgr.Type.VoiceSub) * 0.01f);
  251. this.mix_mgr.SetVolume(AudioMixerMgr.Group.VoiceExtra, (float)this.GetVolume(AudioSourceMgr.Type.VoiceExtra) * 0.01f);
  252. this.mix_mgr.SetVolume(AudioMixerMgr.Group.VoiceMob, (float)this.GetVolume(AudioSourceMgr.Type.VoiceMob) * 0.01f);
  253. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Dance, (float)this.GetVolumeDance() * 0.01f);
  254. this.mix_mgr.SetVolume(AudioMixerMgr.Group.System, (float)this.GetVolume(AudioSourceMgr.Type.System) * 0.01f);
  255. this.mix_mgr.SetVolume(AudioMixerMgr.Group.SE, (float)this.GetVolume(AudioSourceMgr.Type.Se) * 0.01f);
  256. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  257. {
  258. this.m_listAudioManChara[i].ApplyThreeD();
  259. }
  260. this.m_AudioDummyVoice.ApplyThreeD();
  261. this.m_AudioFadeBufBgm.Apply();
  262. this.m_AudioFadeBufEnv.Apply();
  263. this.m_AudioSeBufSe.Apply();
  264. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  265. {
  266. keyValuePair.Value.ApplyThreeD();
  267. }
  268. }
  269. public bool SaveIni(XElement f_xe)
  270. {
  271. XElement[] array = new XElement[9];
  272. XElement[] array2 = new XElement[9];
  273. for (int i = 0; i < 9; i++)
  274. {
  275. XElement[] array3 = array;
  276. int num = i;
  277. AudioSourceMgr.Type type = (AudioSourceMgr.Type)i;
  278. array3[num] = new XElement(type.ToString() + "Volume", this.GetVolume((AudioSourceMgr.Type)i));
  279. XElement[] array4 = array2;
  280. int num2 = i;
  281. AudioSourceMgr.Type type2 = (AudioSourceMgr.Type)i;
  282. array4[num2] = new XElement(type2.ToString() + "ThreeD", this.GetThreeD((AudioSourceMgr.Type)i));
  283. }
  284. XElement content = new XElement("Sound", new object[]
  285. {
  286. new XElement("VolumeAll", this.GetVolumeAll()),
  287. new XElement("VolumeDance", this.GetVolumeDance()),
  288. array,
  289. array2
  290. });
  291. f_xe.Add(content);
  292. return true;
  293. }
  294. public bool LoadIni(XElement f_xe, int version)
  295. {
  296. XElement xelement = f_xe.Element("Sound");
  297. this.SetVolumeAll(int.Parse(xelement.Element("VolumeAll").Value));
  298. XElement xelement2 = xelement.Element("VolumeDance");
  299. if (xelement2 != null)
  300. {
  301. this.SetVolumeDance(int.Parse(xelement2.Value));
  302. }
  303. for (int i = 0; i < 9; i++)
  304. {
  305. XContainer xcontainer = xelement;
  306. AudioSourceMgr.Type type = (AudioSourceMgr.Type)i;
  307. XElement xelement3 = xcontainer.Element(type.ToString() + "Volume");
  308. if (xelement3 != null)
  309. {
  310. this.SetVolume((AudioSourceMgr.Type)i, int.Parse(xelement3.Value));
  311. }
  312. else
  313. {
  314. this.SetVolume((AudioSourceMgr.Type)i, 100);
  315. }
  316. }
  317. for (int j = 0; j < 9; j++)
  318. {
  319. XContainer xcontainer2 = xelement;
  320. AudioSourceMgr.Type type2 = (AudioSourceMgr.Type)j;
  321. XElement xelement4 = xcontainer2.Element(type2.ToString() + "ThreeD");
  322. if (xelement4 != null)
  323. {
  324. this.SetThreeD((AudioSourceMgr.Type)j, bool.Parse(xelement4.Value));
  325. }
  326. else
  327. {
  328. this.SetThreeD((AudioSourceMgr.Type)j, true);
  329. }
  330. }
  331. if (version <= 1240 && this.GetThreeD(AudioSourceMgr.Type.Voice))
  332. {
  333. this.SetThreeD(AudioSourceMgr.Type.Voice, false);
  334. }
  335. return true;
  336. }
  337. public static Dictionary<string, AudioClip> dicAudioClip = new Dictionary<string, AudioClip>();
  338. private List<AudioSourceMgr> m_listAudioManChara = new List<AudioSourceMgr>();
  339. private SoundMgr.AudioFadeBuffer m_AudioFadeBufBgm;
  340. private SoundMgr.AudioFadeBuffer m_AudioFadeBufEnv;
  341. private SoundMgr.AudioMultiBuffer m_AudioSeBufSe;
  342. private Dictionary<string, AudioSourceMgr> m_dicAudioSystem = new Dictionary<string, AudioSourceMgr>();
  343. private Transform m_trAudioSystem;
  344. private GameObject m_goAudioMgr;
  345. private int m_nAllVol = 50;
  346. private int m_nDanceVol;
  347. private int[] m_nVol = new int[9];
  348. private bool[] m_bThreeD = new bool[9];
  349. public bool compatibilityMode;
  350. private string[] m_arySeFileName = new string[]
  351. {
  352. "SE001.ogg",
  353. "SE002.ogg",
  354. "SE003.ogg",
  355. "SE004.ogg",
  356. string.Empty,
  357. string.Empty
  358. };
  359. private abstract class AAudioMultiBuffer
  360. {
  361. public AAudioMultiBuffer(AudioSourceMgr.Type f_eType, string f_strPrefab, int f_nBufNum, bool f_bThreeD, SoundMgr f_gcSounMgr, GameObject f_goParent)
  362. {
  363. this.m_SoundMgr = f_gcSounMgr;
  364. this.m_aryAudioMan = new AudioSourceMgr[f_nBufNum];
  365. this.m_trParent = new GameObject("AudioSet-" + f_eType.ToString() + "-" + f_strPrefab).transform;
  366. this.m_trParent.SetParent(f_goParent.transform, false);
  367. for (int i = 0; i < f_nBufNum; i++)
  368. {
  369. GameObject original = Resources.Load("System/Prefab/" + f_strPrefab) as GameObject;
  370. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  371. this.m_aryAudioMan[i] = gameObject.GetComponentsInChildren<AudioSourceMgr>(true)[0];
  372. this.m_aryAudioMan[i].Init(f_eType, f_bThreeD, f_gcSounMgr, this.m_trParent);
  373. }
  374. }
  375. public abstract void Play(string f_strFileName, float f_fTime, bool f_bLoop, bool f_bStreaming, Transform f_trAttachParent);
  376. public abstract void Stop(float f_fTime);
  377. public abstract void Apply();
  378. public virtual AudioSource GetActiveAudioSource()
  379. {
  380. return this.m_asActive;
  381. }
  382. public abstract string GetActivePlay();
  383. public virtual void Clear()
  384. {
  385. if (this.m_aryAudioMan != null)
  386. {
  387. foreach (AudioSourceMgr audioSourceMgr in this.m_aryAudioMan)
  388. {
  389. audioSourceMgr.Clear();
  390. }
  391. }
  392. }
  393. protected AudioSourceMgr[] m_aryAudioMan;
  394. protected SoundMgr m_SoundMgr;
  395. protected Transform m_trParent;
  396. protected AudioSource m_asActive;
  397. }
  398. private class AudioFadeBuffer : SoundMgr.AAudioMultiBuffer
  399. {
  400. public AudioFadeBuffer(AudioSourceMgr.Type f_eType, string f_strPrefab, int f_nBufNum, bool f_bThreeD, SoundMgr f_gcSounMgr, GameObject f_goParent) : base(f_eType, f_strPrefab, f_nBufNum, f_bThreeD, f_gcSounMgr, f_goParent)
  401. {
  402. }
  403. public override void Play(string f_strFileName, float f_fTime, bool f_bStreaming, bool f_bLoop, Transform f_trAttachParent)
  404. {
  405. this.PlayEx(f_strFileName, f_fTime, f_bStreaming, f_bLoop, f_trAttachParent, false);
  406. }
  407. public void PlayEx(string f_strFileName, float f_fTime, bool f_bStreaming, bool f_bLoop, Transform f_trAttachParent, bool f_bDance)
  408. {
  409. if (this.m_aryAudioMan[this.m_nBgmActiveNo].isPlay() && this.m_aryAudioMan[this.m_nBgmActiveNo].FileName == f_strFileName && this.m_aryAudioMan[this.m_nBgmActiveNo].isLastPlayCompatibilityMode == this.m_SoundMgr.compatibilityMode)
  410. {
  411. Debug.Log("同じファイル名が再生中なので再生を拒否:" + f_strFileName);
  412. return;
  413. }
  414. this.m_aryAudioMan[this.m_nBgmActiveNo].Stop(f_fTime);
  415. int num = -1;
  416. int num2 = -1;
  417. float num3 = 1f;
  418. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  419. {
  420. if (this.m_nBgmActiveNo != i)
  421. {
  422. AudioSourceMgr audioSourceMgr = this.m_aryAudioMan[i];
  423. if (!audioSourceMgr.isPlay())
  424. {
  425. num = i;
  426. }
  427. if (audioSourceMgr.FadeVolume <= num3)
  428. {
  429. num3 = audioSourceMgr.FadeVolume;
  430. num2 = i;
  431. }
  432. }
  433. }
  434. if (num == -1)
  435. {
  436. if (num2 == -1)
  437. {
  438. for (int j = 0; j < this.m_aryAudioMan.Length; j++)
  439. {
  440. if (this.m_nBgmActiveNo != j)
  441. {
  442. this.m_nBgmActiveNo = j;
  443. break;
  444. }
  445. }
  446. }
  447. else
  448. {
  449. this.m_nBgmActiveNo = num2;
  450. }
  451. }
  452. else
  453. {
  454. this.m_nBgmActiveNo = num;
  455. }
  456. AudioSourceMgr audioSourceMgr2 = this.m_aryAudioMan[this.m_nBgmActiveNo];
  457. audioSourceMgr2.Stop();
  458. if (f_bDance)
  459. {
  460. audioSourceMgr2.LoadPlayDanceBGM(f_strFileName, f_fTime, f_bStreaming, f_bLoop);
  461. }
  462. else
  463. {
  464. audioSourceMgr2.LoadPlay(f_strFileName, f_fTime, f_bStreaming, f_bLoop);
  465. }
  466. audioSourceMgr2.SetParent(f_trAttachParent);
  467. this.m_asActive = audioSourceMgr2.GetComponent<AudioSource>();
  468. }
  469. public override void Stop(float f_fTime)
  470. {
  471. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  472. {
  473. this.m_aryAudioMan[i].Stop(f_fTime);
  474. }
  475. }
  476. public override void Apply()
  477. {
  478. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  479. {
  480. this.m_aryAudioMan[i].ApplyThreeD();
  481. }
  482. }
  483. public override string GetActivePlay()
  484. {
  485. return this.m_aryAudioMan[this.m_nBgmActiveNo].FileName;
  486. }
  487. private int m_nBgmActiveNo;
  488. }
  489. private class AudioMultiBuffer : SoundMgr.AAudioMultiBuffer
  490. {
  491. public AudioMultiBuffer(AudioSourceMgr.Type f_eType, string f_strPrefab, int f_nBufNum, bool f_bThreeD, SoundMgr f_gcSounMgr, GameObject f_goParent) : base(f_eType, f_strPrefab, f_nBufNum, f_bThreeD, f_gcSounMgr, f_goParent)
  492. {
  493. this.m_aryTime = new float[f_nBufNum];
  494. }
  495. public override void Play(string f_strFileName, float f_fTime, bool f_bStreaming, bool f_bLoop, Transform f_trAttachParent)
  496. {
  497. int num = -1;
  498. int num2 = -1;
  499. float num3 = Time.time;
  500. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  501. {
  502. AudioSourceMgr audioSourceMgr = this.m_aryAudioMan[i];
  503. if (audioSourceMgr.isPlay() && audioSourceMgr.isLoop())
  504. {
  505. if (audioSourceMgr.FileName == f_strFileName)
  506. {
  507. return;
  508. }
  509. }
  510. else
  511. {
  512. if (!audioSourceMgr.isPlay())
  513. {
  514. num = i;
  515. }
  516. if (this.m_aryTime[i] < num3)
  517. {
  518. num3 = this.m_aryTime[i];
  519. num2 = i;
  520. }
  521. }
  522. }
  523. int num4;
  524. if (num == -1)
  525. {
  526. if (num2 == -1)
  527. {
  528. num4 = UnityEngine.Random.Range(0, this.m_aryAudioMan.Length);
  529. }
  530. else
  531. {
  532. num4 = num2;
  533. }
  534. }
  535. else
  536. {
  537. num4 = num;
  538. }
  539. this.m_aryAudioMan[num4].LoadPlay(f_strFileName, f_fTime, f_bStreaming, f_bLoop);
  540. this.m_aryAudioMan[num4].SetParent(f_trAttachParent);
  541. this.m_aryTime[num4] = Time.time;
  542. this.m_asActive = this.m_aryAudioMan[num4].GetComponent<AudioSource>();
  543. }
  544. public override void Stop(float f_fTime)
  545. {
  546. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  547. {
  548. this.m_aryAudioMan[i].Stop(f_fTime);
  549. }
  550. }
  551. public void Stop(float f_fTime, string f_strFileName)
  552. {
  553. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  554. {
  555. AudioSourceMgr audioSourceMgr = this.m_aryAudioMan[i];
  556. if (audioSourceMgr.isPlay() && audioSourceMgr.FileName == f_strFileName)
  557. {
  558. audioSourceMgr.Stop(f_fTime);
  559. }
  560. }
  561. }
  562. public override void Apply()
  563. {
  564. for (int i = 0; i < this.m_aryAudioMan.Length; i++)
  565. {
  566. this.m_aryAudioMan[i].ApplyThreeD();
  567. }
  568. }
  569. public override string GetActivePlay()
  570. {
  571. return string.Empty;
  572. }
  573. private float[] m_aryTime;
  574. }
  575. public enum SeType
  576. {
  577. Click,
  578. IClick,
  579. Cancel,
  580. Hover,
  581. Self,
  582. Non
  583. }
  584. }