private static void loadTalent(XmlNode TalentNode, Charakter charakter) { String Name = null; String Taw = null; String AT = null; String PA = null; foreach (XmlNode node in TalentNode) { switch (node.Name) { case ManagmentXMLStrings.Name: Name = node.InnerText; break; case ManagmentXMLStrings.TAW: Taw = node.InnerText; break; case ManagmentXMLStrings.attack: AT = node.InnerText; break; case ManagmentXMLStrings.Parade: PA = node.InnerText; break; default: throw new Exception(); } } Name = Name.Replace(".", " "); InterfaceTalent talent = charakter.getTalent(Name); if (talent == null) { return; } talent.setTaw(Taw); if (AT != null & PA != null) { TalentFighting ftalent = (TalentFighting)talent; int x = 0; Int32.TryParse(AT, out x); ftalent.setAT(x); Int32.TryParse(PA, out x); ftalent.setPA(x); } }
//######################################################################################################################## //TalentPage private static void saveTalents(Charakter charakter, XmlDocument characterFile, XmlElement element) { XmlElement GeneralElement = characterFile.CreateElement(ManagmentXMLStrings.GeneralTalent); XmlElement FightingElement = characterFile.CreateElement(ManagmentXMLStrings.FightingTalent); XmlElement LanguageElement = characterFile.CreateElement(ManagmentXMLStrings.Language); XmlElement GiftElement = characterFile.CreateElement(ManagmentXMLStrings.Gifts); Dictionary <String, XmlNode> familyNodes = new Dictionary <string, XmlNode>(0); List <InterfaceTalent> talentList = charakter.getTalentList_allTalents(); for (int i = 0; i < talentList.Count; i++) { if (talentList[i] as TalentGeneral != null) { saveTalent(talentList[i], characterFile, GeneralElement); } else if (talentList[i] as TalentFighting != null) { TalentFighting fighting = (TalentFighting)talentList[i]; XmlElement TElement = saveTalent(talentList[i], characterFile, FightingElement); String pa = fighting.getPA(); String at = fighting.getAT().ToString(); XmlElement atElement = characterFile.CreateElement(ManagmentXMLStrings.attack); XmlElement paElement = characterFile.CreateElement(ManagmentXMLStrings.Parade); TElement.AppendChild(atElement).InnerText = at; TElement.AppendChild(paElement).InnerText = pa; } else if (talentList[i] as LanguageAbstractTalent != null) { LanguageAbstractTalent ltalent = (LanguageAbstractTalent)talentList[i]; String motherMark = ltalent.getMotherMark(); XmlElement LElement = saveTalent(talentList[i], characterFile, LanguageElement); XmlElement motherMarkElement = characterFile.CreateElement(ManagmentXMLStrings.SpeakingMother); motherMarkElement.InnerText = motherMark; if (0 == String.Compare("", motherMark)) { LElement.AppendChild(motherMarkElement); } } else if (talentList[i] as GiftTalent != null) { GiftTalent talent = (GiftTalent)talentList[i]; saveTalent(talentList[i], characterFile, GiftElement); } } element.AppendChild(GeneralElement); element.AppendChild(FightingElement); element.AppendChild(LanguageElement); element.AppendChild(GiftElement); }
private static void loadTalentNode(XmlNode TalentNode, Charakter charakter) { String Name = null; String Taw = null; String AT = null; String PA = null; String speakingMother = null; foreach (XmlNode node in TalentNode) { switch (node.Name) { case ManagmentXMLStrings.Name: Name = node.InnerText; break; case ManagmentXMLStrings.TAW: Taw = node.InnerText; break; case ManagmentXMLStrings.attack: AT = node.InnerText; break; case ManagmentXMLStrings.Parade: PA = node.InnerText; break; case ManagmentXMLStrings.SpeakingMother: speakingMother = node.InnerText; break; default: throw new Exception(node.Name + " " + node.InnerText); } } if (Name == null) { Exception e = new MissingMemberException("Corrput File. Talent Without Name"); Log.throwError(e); throw e; } Name = Name.Replace(".", " "); InterfaceTalent talent = charakter.getTalent(Name); if (talent == null) { talent = tControll.getTalent(Name); if (talent == null) { Log.writeLogLine("LoadCharakterXML: Das Talent exestiert im aktuellen Kontext nicht " + Name); return; } charakter.addTalent(talent); } talent.setTaw(Taw); if (AT != null & PA != null) { TalentFighting ftalent = (TalentFighting)talent; int x = 0; Int32.TryParse(AT, out x); ftalent.setAT(x); Int32.TryParse(PA, out x); ftalent.setPA(x); } if (speakingMother != null) { LanguageAbstractTalent lt = (LanguageAbstractTalent)talent; lt.setMotherMark(speakingMother); } }