public static void PlayVoice(string name, string voice, bool loop = false, float volume = 0.65f) { if (name == null) { throw new CYFException("NewAudio.PlayVoice: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); } if (voice == null) { throw new CYFException("NewAudio.PlayVoice: The second argument (the voice name) is nil.\n\nSee the documentation for proper usage."); } if (!audiolist.ContainsKey(name)) { throw new CYFException("The audio channel " + name + " doesn't exist."); } ((AudioSource)audiolist[name]).Stop(); ((AudioSource)audiolist[name]).loop = loop; ((AudioSource)audiolist[name]).volume = volume; ((AudioSource)audiolist[name]).clip = AudioClipRegistry.GetVoice(voice); audiolist[name] = ((AudioSource)audiolist[name]); audioname[name] = "voice:" + voice.ToLower(); if (name == "src") { MusicManager.filename = "voice:" + voice.ToLower(); } ((AudioSource)audiolist[name]).Play(); }
private static UnderFont getUnderFont(string fontName) { XmlDocument xml = new XmlDocument(); string fontPath = FileLoader.requireFile("Sprites/UI/Fonts/" + fontName + ".png"); string xmlPath = FileLoader.requireFile("Sprites/UI/Fonts/" + fontName + ".xml", false); if (xmlPath == null) { return(null); } xml.Load(xmlPath); Dictionary <char, Sprite> fontMap = loadBuiltinFont(xml["font"]["spritesheet"], fontPath); AudioClip defaultVoice = null; if (xml["font"]["voice"] != null) { defaultVoice = AudioClipRegistry.GetVoice(xml["font"]["voice"].InnerText); } UnderFont underfont = new UnderFont(fontMap, defaultVoice); if (xml["font"]["linespacing"] != null) { underfont.LineSpacing = ParseUtil.getFloat(xml["font"]["linespacing"].InnerText); } if (xml["font"]["color"] != null) { underfont.DefaultColor = ParseUtil.getColor(xml["font"]["color"].InnerText); } return(underfont); }
private void inUpdateControlCommand(string command) { string[] cmds = command.Split(':'); string[] args = new string[0]; if (cmds.Length == 2) { args = cmds[1].Split(','); cmds[1] = args[0]; } switch (cmds[0].ToLower()) { case "w": letterTimer = timePerLetter - (singleFrameTiming * ParseUtil.getInt(cmds[1])); break; case "waitall": timePerLetter = singleFrameTiming * ParseUtil.getInt(cmds[1]); break; case "voice": if (cmds[1].ToLower() == "default") { letterSound.clip = SpriteFontRegistry.Get(SpriteFontRegistry.UI_DEFAULT_NAME).Sound; } else { letterSound.clip = AudioClipRegistry.GetVoice(cmds[1].ToLower()); } break; case "font": letterSound.clip = SpriteFontRegistry.Get(cmds[1].ToLower()).Sound; break; case "novoice": letterSound.clip = null; break; case "next": autoSkip = true; break; case "func": if (caller == null) { UnitaleUtil.displayLuaError("???", "Func called but no script to reference. This is the engine's fault, not yours."); } if (args.Length > 1) { caller.Call(args[0], DynValue.NewString(args[1])); } else { caller.Call(cmds[1]); } break; } }
public void SetVoice(string voiceName) { if (voiceName == null) { throw new CYFException("Text.SetVoice: The first argument (the voice name) is nil.\n\nSee the documentation for proper usage."); } CheckExists(); default_voice = voiceName == "none" ? null : AudioClipRegistry.GetVoice(voiceName); }
public void SetVoice(string voiceName) { if (voiceName == "none") { default_voice = null; } else { default_voice = AudioClipRegistry.GetVoice(voiceName); } }
private static UnderFont GetUnderFont(string fontName) { XmlDocument xml = new XmlDocument(); string fontPath = FileLoader.requireFile("Sprites/UI/Fonts/" + fontName + ".png"); string xmlPath = FileLoader.requireFile("Sprites/UI/Fonts/" + fontName + ".xml", false); if (xmlPath == null) { return(null); } try { xml.Load(xmlPath); } catch (XmlException ex) { UnitaleUtil.DisplayLuaError("Instanciating a font", "An error was encountered while loading the font \"" + fontName + "\":\n\n" + ex.Message); return(null); } if (xml["font"] == null) { UnitaleUtil.DisplayLuaError("Instanciating a font", "The font '" + fontName + "' doesn't have a font element at its root."); return(null); } Dictionary <char, Sprite> fontMap = LoadBuiltInFont(xml["font"]["spritesheet"], fontPath); UnderFont underfont; try { underfont = new UnderFont(fontMap, fontName); } catch { UnitaleUtil.DisplayLuaError("Instanciating a font", "The fonts need a space character to compute their line height, and the font '" + fontName + "' doesn't have one."); return(null); } if (xml["font"]["voice"] != null) { underfont.Sound = AudioClipRegistry.GetVoice(xml["font"]["voice"].InnerText); } if (xml["font"]["linespacing"] != null) { underfont.LineSpacing = ParseUtil.GetFloat(xml["font"]["linespacing"].InnerText); } if (xml["font"]["charspacing"] != null) { underfont.CharSpacing = ParseUtil.GetFloat(xml["font"]["charspacing"].InnerText); } if (xml["font"]["color"] != null) { underfont.DefaultColor = ParseUtil.GetColor(xml["font"]["color"].InnerText); } return(underfont); }
public static void PlayVoice(string name, string voice, bool loop = false, float volume = 0.65f) { if (!audiolist.ContainsKey(name)) { throw new CYFException("The audio channel " + name + " doesn't exist."); } ((AudioSource)audiolist[name]).Stop(); ((AudioSource)audiolist[name]).loop = loop; ((AudioSource)audiolist[name]).volume = volume; ((AudioSource)audiolist[name]).clip = AudioClipRegistry.GetVoice(voice); audiolist[name] = ((AudioSource)audiolist[name]); audioname[name] = "voice:" + voice.ToLower(); if (name == "src") { MusicManager.filename = "voice:" + voice.ToLower(); } ((AudioSource)audiolist[name]).Play(); }