/// <summary> /// parse an xml node /// </summary> /// <param name="xnod"></param> /// <param name="level"></param> public override void LoadFromXml(XmlNode xnod, int level) { LoadNodeFromXml(xnod, level); if (xnod.Name == "Name") Name = xnod.InnerText; if (xnod.Name == "isMale") isMale = Convert.ToBoolean(xnod.InnerText); if (xnod.Name == "DateOfBirth") SetDateOfBirth(DateTime.Parse(xnod.InnerText)); if (xnod.Name == "PhysicalAttributes") { } if (xnod.Name == "EyeColour") EyeColour = xnod.InnerText; if (xnod.Name == "HairColour") HairColour = xnod.InnerText; if (xnod.Name == "HairLength") HairLength = xnod.InnerText; if (xnod.Name == "FacialHair") FacialHair = xnod.InnerText; if (xnod.Name == "BodyBuild") BodyBuild = xnod.InnerText; if (xnod.Name == "Height") Height = xnod.InnerText; if (xnod.Name == "PersonalityAttributes") { } if (xnod.Name == "Extroversion") Extroversion = truthvalue.FromString(xnod.InnerText); if (xnod.Name == "Agreeableness") Agreeableness = truthvalue.FromString(xnod.InnerText); if (xnod.Name == "Conscientiousness") Conscientiousness = truthvalue.FromString(xnod.InnerText); if (xnod.Name == "Neuroticism") Neuroticism = truthvalue.FromString(xnod.InnerText); if (xnod.Name == "Openness") Openness = truthvalue.FromString(xnod.InnerText); if (xnod.Name == "Sexuality") Sexuality = xnod.InnerText; if (xnod.Name == "Beliefs") { beliefs.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { belief b = new belief(); b.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); beliefs.Add(b); } } if (xnod.Name == "Roles") { roles.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { role r = new role(); r.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); roles.Add(r); } } if (xnod.Name == "Possessions") { possessions.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { possession p = new possession(); p.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); possessions.Add(p); } } if (xnod.Name == "Relationships") { relationships.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { relationship r = new relationship(); r.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); relationships.Add(r); } } if (xnod.Name == "GeneralSkills") { generalskills.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { skill s = new skill(); s.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); generalskills.Add(s); } } if (xnod.Name == "Opinions") { opinions.Clear(); for (int i = 0; i < xnod.ChildNodes.Count; i++) { opinion o = new opinion(); o.LoadFromXml((XmlNode)(xnod.ChildNodes[i]), level); opinions.Add(o); } } // call recursively on all children of the current node if (xnod.HasChildNodes) { XmlNode xnodWorking = xnod.FirstChild; while (xnodWorking != null) { LoadFromXml(xnodWorking, level + 1); xnodWorking = xnodWorking.NextSibling; } } }
/// <summary> /// add a relationship /// </summary> /// <param name="Type">the type of relationship, such as mother or father</param> /// <param name="person">person object</param> public void AddRelationship(String Type, personality person, DateTime started, DateTime ended, bool hasEnded, float affect, float credibility, float familiarity) { int index = RelationshipExists(Type, person); relationship r = null; if (index == -1) { r = new relationship(Type, person, this); relationships.Add(r); } else { r = (relationship)relationships[index]; } r.SetStartedDate(started); r.SetEndedDate(ended); r.hasEnded = hasEnded; r.affect = new truthvalue(affect); r.credibility = new truthvalue(credibility); r.familiarity = new truthvalue(familiarity); }