public void StopSFX(SFXList type) { foreach (var entry in entries) { if (entry.type == type) { entry.sound.Stop(); } } }
public void PlaySFX(SFXList type) { foreach (var entry in entries) { if (entry.type == type) { entry.sound.Play(); } } }
public void PlaySoundEffect(string _soundName) { SFXList s = Array.Find(sounds, sound => sound.soundName == _soundName); if (s == null) { Debug.LogWarning(_soundName + " not found."); return; } s.source.Play(); }
public static SFXList LoadSFXList(string path) { StreamReader reader = new StreamReader(path); var saveDataJson = reader.ReadToEnd(); reader.Close(); SFXList sfxList = JsonUtility.FromJson <SFXList>(saveDataJson); return(sfxList); }
public bool PlaySFX(SFXList soundIndex, float pitch = 1.0f, float volume = 1.0f) { if (m_SFXClips.Length - 1 < (int)soundIndex) { return(false); } m_SFXSource[m_iSESourceIndex].clip = m_SFXClips[(int)soundIndex]; m_SFXSource[m_iSESourceIndex].volume = volume; m_SFXSource[m_iSESourceIndex].pitch = pitch; m_SFXSource[m_iSESourceIndex].Play(); m_iSESourceIndex++; m_iSESourceIndex = m_iSESourceIndex % 5; return(true); }
public static void CreateSFX() { string classDefinition = string.Empty; classDefinition += "public class SFX\n"; classDefinition += "{\n"; SFXList sfxList = SFXList.LoadSFXList(InputConfigPath); foreach (string sound in sfxList.SFX) { classDefinition += string.Format("\tpublic const string {0} = \"{0}\";\n", sound); } classDefinition += "}\n"; File.WriteAllText(OutputPath, classDefinition); }
public SFXList LoadSound(string name, SoundEffect data) { name = name.ToLower(); if (sounds.ContainsKey(name)) { if (ContentDuplicateBehavior == ContentDuplicateBehaviors.Replace) { sounds.Remove(name); } else { return(sounds[name]); } } var sfxlist = new SFXList { data }; sounds.Add(name, sfxlist); return(sfxlist); }
public SFXList LoadSounds(string name, params string[] paths) { SFXList sfxlist = new SFXList(); foreach (var item in paths) { sfxlist.AddRange(LoadSound(item)); } if (sounds.ContainsKey(name)) { if (ContentDuplicateBehavior == ContentDuplicateBehaviors.Replace) { sounds.Remove(name); } else { return(sounds[name]); } } sounds.Add(name, sfxlist); return(sfxlist); }