Exemple #1
0
        public static ItemRequire Parse(IEnumerable <XElement> nodes)
        {
            ItemRequire rst = new ItemRequire();

            try
            {
                foreach (var trigger in nodes)
                {
                    string name  = Tools.GetXmlAttribute(trigger, "name");
                    string argvs = Tools.GetXmlAttribute(trigger, "argvs");
                    if (name == "talent")
                    {
                        rst.TalentAttributes.Add(argvs);
                    }
                    else
                    {
                        rst.Attributes[name] = int.Parse(argvs);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("invalid item require type!" + e.ToString());
                return(null);
            }
            return(rst);
        }
Exemple #2
0
        static public Item Parse(XElement node)
        {
            Item rst = new Item();

            rst.myNode  = node;
            rst.Name    = Tools.GetXmlAttribute(node, "name");
            rst.Info    = Tools.GetXmlAttribute(node, "desc");
            rst.PicInfo = Tools.GetXmlAttribute(node, "pic");
            rst.Type    = Tools.GetXmlAttributeInt(node, "type");
            rst.level   = Tools.GetXmlAttributeInt(node, "level");
            if (node.Attribute("price") != null)
            {
                rst.price = Tools.GetXmlAttributeInt(node, "price");
            }
            else
            {
                rst.price = 0;
            }

            /*if (node.Attribute("yuanbao") != null)
             * {
             *  rst.yuanbao = Tools.GetXmlAttributeInt(node, "yuanbao");
             * }
             * else
             * {
             *  rst.yuanbao = 0;
             * }*/

            if (node.Attribute("talent") != null)
            {
                foreach (var t in Tools.GetXmlAttribute(node, "talent").Split(new char[] { '#' }))
                {
                    rst.Talent.Add(t);
                }
            }

            if (node.Attribute("cd") != null)
            {
                rst.Cooldown = Tools.GetXmlAttributeInt(node, "cd");
            }

            if (Tools.GetXmlElements(node, "require") != null)
            {
                rst.Require = ItemRequire.Parse(Tools.GetXmlElements(node, "require"));
            }

            if (Tools.GetXmlElements(node, "trigger") != null)
            {
                foreach (var trigger in Tools.GetXmlElements(node, "trigger"))
                {
                    rst.Triggers.Add(ItemTrigger.Parse(trigger));
                }
            }

            if (node.Attribute("drop") != null)
            {
                rst.IsDrop = bool.Parse(Tools.GetXmlAttribute(node, "drop"));
            }

            //rst.Trigger = Tools.GetXmlAttribute(node, "trigger");
            //rst.Args = Tools.GetXmlAttribute(node, "args");
            return(rst);
        }