public static void playHeroVoice(string heroid, bool stop = false, GameObject gm = null) { if (AudioMgr.Instance.isVoiceMute()) { return; } if (string.IsNullOrEmpty(heroid)) { return; } AudioGameDataLoader.instance.Load(); List <AudioGameDataLoader.audioBindstruct> list = null; if (AudioGameDataLoader.instance._heroVoice.ContainsKey(heroid)) { list = AudioGameDataLoader.instance._heroVoice[heroid]; } if (list == null) { return; } AudioGameDataLoader.audioBindstruct audioBindstruct = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "Select"); if (audioBindstruct != null) { AudioMgr.Play(audioBindstruct.eventstr, gm, stop, false); } }
public void loadToAudioXml() { this.clearaudioBind(); this.loaded = true; string text = "Assets/Resources/AudioBind.xml"; XmlDocument xmlDocument; if (!File.Exists(text)) { xmlDocument = new XmlDocument(); TextAsset textAsset = Resources.Load("AudioBind", typeof(TextAsset)) as TextAsset; if (!(textAsset != null)) { return; } xmlDocument.Load(new MemoryStream(textAsset.bytes)); } else { xmlDocument = new XmlDocument(); xmlDocument.Load(text); } XmlElement documentElement = xmlDocument.DocumentElement; if (documentElement == null) { xmlDocument.Load(Application.dataPath + "Resources/AudioBind.xml"); documentElement = xmlDocument.DocumentElement; } if (documentElement == null) { return; } XmlNodeList xmlNodeList = documentElement.SelectNodes("/HeroAudio"); XmlNodeList xmlNodeList2 = xmlNodeList[0].SelectNodes("Hero"); foreach (XmlNode xmlNode in xmlNodeList2) { XmlElement xmlElement = (XmlElement)xmlNode; string attribute = xmlElement.GetAttribute("name"); if (!this._heroVoice.ContainsKey(attribute)) { this._heroVoice.Add(attribute, new List <AudioGameDataLoader.audioBindstruct>()); } XmlNodeList xmlNodeList3 = xmlElement.SelectNodes("binder"); foreach (XmlNode xmlNode2 in xmlNodeList3) { AudioGameDataLoader.audioBindstruct audioBindstruct = new AudioGameDataLoader.audioBindstruct(); XmlElement xmlElement2 = (XmlElement)xmlNode2; audioBindstruct.idx = int.Parse(xmlElement2.GetAttribute("idx")); audioBindstruct.desc = xmlElement2.GetAttribute("desc"); audioBindstruct.eventstr = xmlElement2.GetAttribute("event"); audioBindstruct.time = float.Parse(xmlElement2.GetAttribute("time")); if (this._heroVoice[attribute] == null) { this._heroVoice[attribute] = new List <AudioGameDataLoader.audioBindstruct>(); } this._heroVoice[attribute].Add(audioBindstruct); } } xmlNodeList2 = xmlNodeList[0].SelectNodes("Spell"); foreach (XmlNode xmlNode3 in xmlNodeList2) { XmlElement xmlElement3 = (XmlElement)xmlNode3; string attribute2 = xmlElement3.GetAttribute("id"); if (!this._spellSfx.ContainsKey(attribute2)) { this._spellSfx.Add(attribute2, new List <AudioGameDataLoader.audioBindstruct>()); } XmlNodeList xmlNodeList4 = xmlElement3.SelectNodes("binder"); foreach (XmlNode xmlNode4 in xmlNodeList4) { AudioGameDataLoader.audioBindstruct audioBindstruct2 = new AudioGameDataLoader.audioBindstruct(); XmlElement xmlElement4 = (XmlElement)xmlNode4; audioBindstruct2.idx = int.Parse(xmlElement4.GetAttribute("idx")); audioBindstruct2.desc = xmlElement4.GetAttribute("desc"); audioBindstruct2.eventstr = xmlElement4.GetAttribute("event"); audioBindstruct2.time = float.Parse(xmlElement4.GetAttribute("time")); if (!string.IsNullOrEmpty(xmlElement4.GetAttribute("endevt"))) { audioBindstruct2.endevent = bool.Parse(xmlElement4.GetAttribute("endevt")); } if (this._spellSfx[attribute2] == null) { this._spellSfx[attribute2] = new List <AudioGameDataLoader.audioBindstruct>(); } this._spellSfx[attribute2].Add(audioBindstruct2); } } }
public void loadSoundData(string heroname) { if (string.IsNullOrEmpty(heroname)) { return; } List <AudioGameDataLoader.audioBindstruct> list = null; if (AudioGameDataLoader.instance._heroVoice.ContainsKey(heroname)) { list = AudioGameDataLoader.instance._heroVoice[heroname]; } if (list == null) { return; } AudioGameDataLoader.audioBindstruct audioBindstruct = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "born"); AudioGameDataLoader.audioBindstruct audioBindstruct2 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "move"); AudioGameDataLoader.audioBindstruct audioBindstruct3 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "die"); AudioGameDataLoader.audioBindstruct audioBindstruct4 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "reborn"); AudioGameDataLoader.audioBindstruct audioBindstruct5 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "Attack"); AudioGameDataLoader.audioBindstruct audioBindstruct6 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "LastKill"); AudioGameDataLoader.audioBindstruct audioBindstruct7 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "Kill"); AudioGameDataLoader.audioBindstruct audioBindstruct8 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "LevelUp"); AudioGameDataLoader.audioBindstruct audioBindstruct9 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "OrgAttack"); AudioGameDataLoader.audioBindstruct audioBindstruct10 = list.Find((AudioGameDataLoader.audioBindstruct x) => x.desc == "Select"); if (audioBindstruct != null) { this.born_event = audioBindstruct.eventstr; } if (audioBindstruct2 != null) { this.moving_event = audioBindstruct2.eventstr; } if (audioBindstruct3 != null) { this.die_event = audioBindstruct3.eventstr; } if (audioBindstruct4 != null) { this.reborn_event = audioBindstruct4.eventstr; } if (audioBindstruct5 != null) { this.attackstart_event = audioBindstruct5.eventstr; } if (audioBindstruct9 != null) { this.attackoral_event = audioBindstruct9.eventstr; } if (audioBindstruct10 != null) { this.heroselected_event = audioBindstruct10.eventstr; } if (audioBindstruct6 != null) { this.bubing_event = audioBindstruct6.eventstr; } if (audioBindstruct8 != null) { this.levelup_event = audioBindstruct8.eventstr; } if (audioBindstruct7 != null) { this.kill3_event = audioBindstruct7.eventstr; } }