public static RandomRole Parse(XElement node) { RandomRole br = new RandomRole(); br.x = Tools.GetXmlAttributeInt(node, "x"); br.y = Tools.GetXmlAttributeInt(node, "y"); if (node.Attribute("face") != null) { br.faceRight = Tools.GetXmlAttributeInt(node, "face") == 0; } return(br); }
public static Battle Parse(XElement node) { Battle battle = new Battle(); battle.xmlNode = node; battle.Key = Tools.GetXmlAttribute(node, "key"); if (battle.Key.Contains(" ")) { MessageBox.Show("错误,BATTLE KEY不能包含空格," + battle.Key); } battle.templateKey = Tools.GetXmlAttribute(node, "template"); if (node.Attribute("xoffset") != null) { battle.xoffset = Tools.GetXmlAttributeInt(node, "xoffset"); } if (node.Attribute("yoffset") != null) { battle.yoffset = Tools.GetXmlAttributeInt(node, "yoffset"); } if (node.Attribute("must") != null) { battle.must = Tools.GetXmlAttribute(node, "must"); } if (node.Attribute("bonus") != null) { battle.bonus = bool.Parse(Tools.GetXmlAttribute(node, "bonus")); } if (node.Attribute("music") != null) { battle._music = Tools.GetXmlAttribute(node, "music"); } if (node.Element("roles") != null) { foreach (XElement role in node.Element("roles").Elements("role")) { battle.battleRoles.Add(BattleRole.Parse(role)); } } if (node.Element("random") != null) { battle.randomRoleLevel = Tools.GetXmlAttributeInt(node.Element("random"), "level"); if (node.Element("random").Attribute("name") != null) { battle.randomRoleName = Tools.GetXmlAttribute(node.Element("random"), "name"); } if (node.Element("random").Attribute("animation") != null) { battle.randomRoleAnimation = Tools.GetXmlAttribute(node.Element("random"), "animation"); } if (node.Element("random").Attribute("boss") != null) { battle.isRandomBoss = bool.Parse(Tools.GetXmlAttribute(node.Element("random"), "boss")); } foreach (XElement role in node.Element("random").Elements("role")) { battle.randomRoles.Add(RandomRole.Parse(role)); } } if (node.Attribute("arena") != null) { battle.arena = Tools.GetXmlAttribute(node, "arena"); } if (node.Element("story") != null) { foreach (var an in node.Element("story").Elements("action")) { battle.Actions.Add(Action.Parse(an)); } } if (node.Element("maxround") != null) { battle.maxRound = Tools.GetXmlAttributeInt(node, "maxround"); } return(battle); }