/// <summary> /// Displaies the dialogue. /// if AnimatedTypingLetter = true, the letters will be typed to screen one by one /// if AnimatedTypingLetter = false. the dialog text will be flashed out to screen in one time. /// </summary> IEnumerator DisplayDialogue(string DialogueID) { LocalizedDialogue dialog = Localization.GetDialogue(DialogueID); HasDialog = true; foreach (LocalizedDialogueItem dialogItem in dialog.dialogueItem) { LocalizeCharacter speaker = Localization.GetCharacter(dialogItem.DialogCharacterID); this.Portrait = speaker.PortraitIconTexture; this.SpearkerName = speaker.CharacterName; float delay = dialogItem.pendAfterFinished.HasValue ? dialogItem.pendAfterFinished.Value : 2; if (!string.IsNullOrEmpty(dialogItem.DialogImageName)) { displayedImage = (Texture)Resources.Load(Localization.DialogAssetRootFolder + "/" + LevelName + "/" + this.targetLanguage + "/" + dialogItem.DialogImageName, typeof(Texture)); } else { displayedImage = null; } yield return(new WaitForSeconds(delay)); } HasDialog = false; }
/// <summary> /// Parses the character localization XML file. /// </summary> static IDictionary<string, LocalizeCharacter> ParseCharacterLocalizationXMLFile(XmlDocument xmlDoc, SystemLanguage language) { IDictionary<string, LocalizeCharacter> ret = new Dictionary<string, LocalizeCharacter>(); XmlElement root = xmlDoc.DocumentElement; XmlNodeList xmlNodeList = root.GetElementsByTagName("character"); foreach (XmlNode node in xmlNodeList) { XmlElement characterElement = (XmlElement)node; LocalizeCharacter localization_Character = new LocalizeCharacter(); localization_Character.CharacterID = characterElement.GetAttribute("id"); ; localization_Character.CharacterName = characterElement.GetAttribute(language.ToString()); ///CharacterIconPath can be empty localization_Character.CharacterIconPath = characterElement.HasAttribute("imagepath") ? characterElement.GetAttribute("imagepath") : string.Empty; ///the image can be null localization_Character.PortraitIconTexture = localization_Character.CharacterIconPath != string.Empty ? (Texture2D)Resources.Load(localization_Character.CharacterIconPath, typeof(Texture2D)) : null; ret.Add(localization_Character.CharacterID, localization_Character); } return ret; }
/// <summary> /// Parses the character localization XML file. /// </summary> static IDictionary <string, LocalizeCharacter> ParseCharacterLocalizationXMLFile(XmlDocument xmlDoc, SystemLanguage language) { IDictionary <string, LocalizeCharacter> ret = new Dictionary <string, LocalizeCharacter>(); XmlElement root = xmlDoc.DocumentElement; XmlNodeList xmlNodeList = root.GetElementsByTagName("character"); foreach (XmlNode node in xmlNodeList) { XmlElement characterElement = (XmlElement)node; LocalizeCharacter localization_Character = new LocalizeCharacter(); localization_Character.CharacterID = characterElement.GetAttribute("id");; localization_Character.CharacterName = characterElement.GetAttribute(language.ToString()); ///CharacterIconPath can be empty localization_Character.CharacterIconPath = characterElement.HasAttribute("imagepath") ? characterElement.GetAttribute("imagepath") : string.Empty; ///the image can be null localization_Character.PortraitIconTexture = localization_Character.CharacterIconPath != string.Empty ? (Texture2D)Resources.Load(localization_Character.CharacterIconPath, typeof(Texture2D)) : null; ret.Add(localization_Character.CharacterID, localization_Character); } return(ret); }