Beispiel #1
0
        /// <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;
                }
            }
        }
Beispiel #2
0
        public role AddRole(society soc, String Profession, String Description,
            DateTime StartedDate,
            String Affect,
            String Locn, String Country, String skills_list)
        {
            role r = null;
            int index = roleExists(Profession, StartedDate);
            if (index == -1)
            {
                r = new role();
                roles.Add(r);
            }
            else
            {
                r = (role)roles[index];
            }
            r.Profession = new profession(Profession);
            r.Description = Description;
            r.Affect = Affect;
            r.SetAcquiredDate(StartedDate);

            if (skills_list != "")
            {
                String[] skills_str = skills_list.Split(',');
                for (int i = 0; i < skills_str.Length; i++)
                {
                    String s = skills_str[i];
                    r.Skills.Add(new skill(s.Trim()));
                }
            }

            int locn_index = soc.LocationExists(Locn, Country);
            if (locn_index > -1)
                r.Locn = (location)soc.locations[locn_index];
            else
                r.Locn = soc.AddLocation(Locn, Country, "");

            return (r);
        }