SoundMgr.cs 17 KB

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