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 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.SetVolumeDance(70);
  64. this.SetThreeD(AudioSourceMgr.Type.Bgm, false);
  65. this.SetThreeD(AudioSourceMgr.Type.Se, true);
  66. this.SetThreeD(AudioSourceMgr.Type.Env, true);
  67. this.SetThreeD(AudioSourceMgr.Type.Voice, true);
  68. }
  69. public void PlayBGM(string f_strFileName, float f_fTime, bool f_fLoop = true)
  70. {
  71. this.m_AudioFadeBufBgm.Play(f_strFileName, f_fTime, true, f_fLoop, null);
  72. }
  73. public void PlayBGMLegacy(string f_strFileName, float f_fTime, bool f_fLoop = true)
  74. {
  75. bool flag = this.compatibilityMode;
  76. this.compatibilityMode = true;
  77. this.m_AudioFadeBufBgm.Play(f_strFileName, f_fTime, true, f_fLoop, null);
  78. this.compatibilityMode = flag;
  79. }
  80. public void PlayDanceBGM(string f_strFileName, float f_fTime, bool f_fLoop = true)
  81. {
  82. this.m_AudioFadeBufBgm.PlayEx(f_strFileName, f_fTime, true, f_fLoop, null, true);
  83. }
  84. public AudioSource GetAudioSourceBgm()
  85. {
  86. return this.m_AudioFadeBufBgm.GetActiveAudioSource();
  87. }
  88. public void StopBGM(float f_fTime)
  89. {
  90. this.m_AudioFadeBufBgm.Stop(f_fTime);
  91. }
  92. public void PlayEnv(string f_strFileName, float f_fTime)
  93. {
  94. this.m_AudioFadeBufEnv.Play(f_strFileName, f_fTime, true, true, null);
  95. }
  96. public void StopEnv(float f_fTime)
  97. {
  98. this.m_AudioFadeBufEnv.Stop(f_fTime);
  99. }
  100. public void PlaySe(string f_strFileName, bool f_bLoop)
  101. {
  102. this.m_AudioSeBufSe.Play(f_strFileName, 0f, false, f_bLoop, null);
  103. }
  104. public void StopSe()
  105. {
  106. this.m_AudioSeBufSe.Stop(0f);
  107. }
  108. public void StopSe(string f_strFileName)
  109. {
  110. this.m_AudioSeBufSe.Stop(0f, f_strFileName);
  111. }
  112. public void PlaySystem(string f_strFileName)
  113. {
  114. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(f_strFileName.ToLower());
  115. AudioSourceMgr audioSourceMgr;
  116. if (!this.m_dicAudioSystem.TryGetValue(fileNameWithoutExtension, out audioSourceMgr))
  117. {
  118. GameObject original = Resources.Load("System/Prefab/AudioSystem") as GameObject;
  119. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  120. audioSourceMgr = gameObject.GetComponentsInChildren<AudioSourceMgr>(true)[0];
  121. audioSourceMgr.Init(AudioSourceMgr.Type.System, false, this, this.m_trAudioSystem.transform);
  122. audioSourceMgr.LoadFromWf(GameUty.FileSystem, f_strFileName, false);
  123. this.m_dicAudioSystem.Add(fileNameWithoutExtension, audioSourceMgr);
  124. }
  125. audioSourceMgr.PlayOneShot();
  126. }
  127. public void PlayDummyVoice(string f_strFileName, float f_fFadeTime = 0f, bool f_bStreaming = false, bool f_bLoop = false, int voice_pitch = 50)
  128. {
  129. this.m_AudioDummyVoice.Pitch = SoundMgr.ConvertToAudioSourcePitch(voice_pitch);
  130. this.m_AudioDummyVoice.LoadPlay(f_strFileName, f_fFadeTime, f_bStreaming, f_bLoop);
  131. }
  132. public void StopDummyVoide()
  133. {
  134. this.m_AudioDummyVoice.Stop();
  135. }
  136. public bool IsPlayDummyVoice()
  137. {
  138. return this.m_AudioDummyVoice.isPlay();
  139. }
  140. public void PlaySystem(SoundMgr.SeType f_eSe)
  141. {
  142. if (f_eSe != SoundMgr.SeType.Non && f_eSe != SoundMgr.SeType.Self)
  143. {
  144. this.PlaySystem(this.m_arySeFileName[(int)f_eSe]);
  145. }
  146. }
  147. public void StopSystem()
  148. {
  149. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  150. {
  151. keyValuePair.Value.Stop();
  152. }
  153. }
  154. public AudioSourceMgr AllocVoice(Transform f_trParent, bool f_bThreeD = true)
  155. {
  156. GameObject original = Resources.Load("System/Prefab/AudioVoice") as GameObject;
  157. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  158. AudioSourceMgr audioSourceMgr = gameObject.GetComponentsInChildren<AudioSourceMgr>(true)[0];
  159. audioSourceMgr.Init(AudioSourceMgr.Type.Voice, f_bThreeD, this, f_trParent);
  160. this.m_listAudioManChara.Add(audioSourceMgr);
  161. return audioSourceMgr;
  162. }
  163. public void FreeVoice(AudioSourceMgr f_gcAudioMan, bool f_bDestoryMe)
  164. {
  165. this.m_listAudioManChara.Remove(f_gcAudioMan);
  166. f_gcAudioMan.Clear();
  167. if (f_bDestoryMe)
  168. {
  169. UnityEngine.Object.Destroy(f_gcAudioMan);
  170. }
  171. f_gcAudioMan = null;
  172. }
  173. public void StopAll()
  174. {
  175. this.VoiceStopAll();
  176. this.StopBGM(0f);
  177. this.StopEnv(0f);
  178. this.StopSe();
  179. this.StopSystem();
  180. }
  181. public void OnDestroy()
  182. {
  183. this.ClearAll();
  184. this.m_AudioFadeBufBgm = null;
  185. this.m_AudioFadeBufEnv = null;
  186. this.m_AudioSeBufSe = null;
  187. this.m_dicAudioSystem.Clear();
  188. this.m_listAudioManChara.Clear();
  189. this.m_AudioDummyVoice = null;
  190. }
  191. public void ClearAll()
  192. {
  193. if (this.m_AudioFadeBufBgm != null)
  194. {
  195. this.m_AudioFadeBufBgm.Clear();
  196. }
  197. if (this.m_AudioFadeBufEnv != null)
  198. {
  199. this.m_AudioFadeBufEnv.Clear();
  200. }
  201. if (this.m_AudioSeBufSe != null)
  202. {
  203. this.m_AudioSeBufSe.Clear();
  204. }
  205. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  206. {
  207. keyValuePair.Value.Clear();
  208. }
  209. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  210. {
  211. this.m_listAudioManChara[i].Clear();
  212. }
  213. if (this.m_AudioDummyVoice != null)
  214. {
  215. this.m_AudioDummyVoice.Clear();
  216. }
  217. }
  218. public bool isVoicePlaying()
  219. {
  220. bool flag = false;
  221. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  222. {
  223. flag |= this.m_listAudioManChara[i].isPlay();
  224. }
  225. return flag | this.m_AudioDummyVoice.isPlay();
  226. }
  227. public void VoiceStopAll()
  228. {
  229. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  230. {
  231. this.m_listAudioManChara[i].Stop();
  232. }
  233. this.m_AudioDummyVoice.Stop();
  234. }
  235. public void Apply()
  236. {
  237. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Master, (float)this.m_nAllVol * 0.01f);
  238. this.mix_mgr.SetVolume(AudioMixerMgr.Group.BGM, (float)this.GetVolume(AudioSourceMgr.Type.Bgm) * 0.01f);
  239. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Voice, (float)this.GetVolume(AudioSourceMgr.Type.Voice) * 0.01f);
  240. this.mix_mgr.SetVolume(AudioMixerMgr.Group.Dance, (float)this.GetVolumeDance() * 0.01f);
  241. this.mix_mgr.SetVolume(AudioMixerMgr.Group.System, (float)this.GetVolume(AudioSourceMgr.Type.System) * 0.01f);
  242. this.mix_mgr.SetVolume(AudioMixerMgr.Group.SE, (float)this.GetVolume(AudioSourceMgr.Type.Se) * 0.01f);
  243. for (int i = 0; i < this.m_listAudioManChara.Count; i++)
  244. {
  245. this.m_listAudioManChara[i].ApplyThreeD();
  246. }
  247. this.m_AudioDummyVoice.ApplyThreeD();
  248. this.m_AudioFadeBufBgm.Apply();
  249. this.m_AudioFadeBufEnv.Apply();
  250. this.m_AudioSeBufSe.Apply();
  251. foreach (KeyValuePair<string, AudioSourceMgr> keyValuePair in this.m_dicAudioSystem)
  252. {
  253. keyValuePair.Value.ApplyThreeD();
  254. }
  255. }
  256. public bool SaveIni(XElement f_xe)
  257. {
  258. XElement[] array = new XElement[5];
  259. XElement[] array2 = new XElement[5];
  260. for (int i = 0; i < 5; i++)
  261. {
  262. XElement[] array3 = array;
  263. int num = i;
  264. AudioSourceMgr.Type type = (AudioSourceMgr.Type)i;
  265. array3[num] = new XElement(type.ToString() + "Volume", this.GetVolume((AudioSourceMgr.Type)i));
  266. XElement[] array4 = array2;
  267. int num2 = i;
  268. AudioSourceMgr.Type type2 = (AudioSourceMgr.Type)i;
  269. array4[num2] = new XElement(type2.ToString() + "ThreeD", this.GetThreeD((AudioSourceMgr.Type)i));
  270. }
  271. XElement content = new XElement("Sound", new object[]
  272. {
  273. new XElement("VolumeAll", this.GetVolumeAll()),
  274. new XElement("VolumeDance", this.GetVolumeDance()),
  275. array,
  276. array2
  277. });
  278. f_xe.Add(content);
  279. return true;
  280. }
  281. public bool LoadIni(XElement f_xe)
  282. {
  283. XElement xelement = f_xe.Element("Sound");
  284. this.SetVolumeAll(int.Parse(xelement.Element("VolumeAll").Value));
  285. XElement xelement2 = xelement.Element("VolumeDance");
  286. if (xelement2 != null)
  287. {
  288. this.SetVolumeDance(int.Parse(xelement2.Value));
  289. }
  290. for (int i = 0; i < 5; i++)
  291. {
  292. AudioSourceMgr.Type f_eType = (AudioSourceMgr.Type)i;
  293. XContainer xcontainer = xelement;
  294. AudioSourceMgr.Type type = (AudioSourceMgr.Type)i;
  295. this.SetVolume(f_eType, int.Parse(xcontainer.Element(type.ToString() + "Volume").Value));
  296. }
  297. for (int j = 0; j < 5; j++)
  298. {
  299. AudioSourceMgr.Type f_eType2 = (AudioSourceMgr.Type)j;
  300. XContainer xcontainer2 = xelement;
  301. AudioSourceMgr.Type type2 = (AudioSourceMgr.Type)j;
  302. this.SetThreeD(f_eType2, bool.Parse(xcontainer2.Element(type2.ToString() + "ThreeD").Value));
  303. }
  304. return true;
  305. }
  306. public static Dictionary<string, AudioClip> dicAudioClip = new Dictionary<string, AudioClip>();
  307. private List<AudioSourceMgr> m_listAudioManChara = new List<AudioSourceMgr>();
  308. private SoundMgr.AudioFadeBuffer m_AudioFadeBufBgm;
  309. private SoundMgr.AudioFadeBuffer m_AudioFadeBufEnv;
  310. private SoundMgr.AudioMultiBuffer m_AudioSeBufSe;
  311. private Dictionary<string, AudioSourceMgr> m_dicAudioSystem = new Dictionary<string, AudioSourceMgr>();
  312. private Transform m_trAudioSystem;
  313. private GameObject m_goAudioMgr;
  314. private int m_nAllVol = 50;
  315. private int m_nDanceVol;
  316. private int[] m_nVol = new int[5];
  317. private bool[] m_bThreeD = new bool[5];
  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. }