public static SpiritInfo parse(XElement node) { XElement subnode = Tools.GetXmlElement(node, "SpiritInfo"); SpiritInfo info = new SpiritInfo(); info.X = Tools.GetXmlAttributeInt(subnode, "X"); info.Y = Tools.GetXmlAttributeInt(subnode, "Y"); info.itemCD = Tools.GetXmlAttributeInt(subnode, "itemCD"); info.faceright = Tools.GetXmlAttributeInt(subnode, "faceright"); return(info); }
public void displayPreBattleEffect(UIHost uihost) { BattleField field = uihost.battleFieldContainer.field; //文字效果 foreach (Spirit sp in field.Spirits) { if (preRoleWords.ContainsKey(sp.battleID)) { field.ShowSmallDialogBox(sp, preRoleWords[sp.battleID], 1.0); } if (preRoleAttackInfo.ContainsKey(sp.battleID)) { foreach (BattleWord battleWord in preRoleAttackInfo[sp.battleID]) { sp.AddAttackInfo(battleWord.word, battleWord.color); } } } //人物属性 foreach (Spirit sp in field.Spirits) { if (preRoles.ContainsKey(sp.battleID)) { sp.Role = preRoles[sp.battleID]; } if (preSpiritInfos.ContainsKey(sp.battleID)) { SpiritInfo info = preSpiritInfos[sp.battleID]; sp.X = info.X; sp.Y = info.Y; sp.FaceRight = info.faceright == 0?false:true; sp.ItemCd = info.itemCD; } sp.Refresh(); } }
public void parse(string rootString) { XElement root = XElement.Parse(rootString); //战斗前数据 preRoles.Clear(); XElement preRolesXML = Tools.GetXmlElement(root, "preRoles"); foreach (XElement preRoleXML in Tools.GetXmlElements(preRolesXML, "preRole")) { int ID = Tools.GetXmlAttributeInt(preRoleXML, "ID"); Role role = Role.Parse(Tools.GetXmlElement(preRoleXML, "role")); preRoles.Add(ID, role); } preSpiritInfos.Clear(); XElement preSpiritInfosXML = Tools.GetXmlElement(root, "preSpiritInfos"); foreach (XElement preSpiritInfoXML in Tools.GetXmlElements(preSpiritInfosXML, "preSpiritInfo")) { int ID = Tools.GetXmlAttributeInt(preSpiritInfoXML, "ID"); SpiritInfo spInfo = SpiritInfo.parse(preSpiritInfoXML); preSpiritInfos.Add(ID, spInfo); } preRoleWords.Clear(); XElement preRoleWordsXML = Tools.GetXmlElement(root, "preRoleWords"); foreach (XElement preRoleWordXML in Tools.GetXmlElements(preRoleWordsXML, "preRoleWord")) { int ID = Tools.GetXmlAttributeInt(preRoleWordXML, "ID"); string word = Tools.GetXmlAttribute(preRoleWordXML, "word"); preRoleWords.Add(ID, word); } preRoleAttackInfo.Clear(); XElement preRoleAttackInfosXML = Tools.GetXmlElement(root, "preRoleAttackInfos"); foreach (XElement preRoleAttackInfoXML in Tools.GetXmlElements(preRoleAttackInfosXML, "preRoleAttackInfo")) { int ID = Tools.GetXmlAttributeInt(preRoleAttackInfoXML, "ID"); List <BattleWord> blist = BattleWord.parse(Tools.GetXmlElement(preRoleAttackInfoXML, "battleWords")); preRoleAttackInfo.Add(ID, blist); } //战斗时数据 XElement moveInfo = Tools.GetXmlElement(root, "moveInfos"); x = Tools.GetXmlAttributeInt(moveInfo, "x"); y = Tools.GetXmlAttributeInt(moveInfo, "y"); faceright = (Tools.GetXmlAttributeInt(moveInfo, "faceright") == 0?false:true); currentSkill = SkillInfo.parse(root); //战斗结果数据 roles.Clear(); XElement rolesXML = Tools.GetXmlElement(root, "roles"); foreach (XElement roleXML in Tools.GetXmlElements(rolesXML, "role")) { int ID = Tools.GetXmlAttributeInt(roleXML, "ID"); Role role = Role.Parse(Tools.GetXmlElement(roleXML, "role")); roles.Add(ID, role); } spiritInfos.Clear(); XElement spiritInfosXML = Tools.GetXmlElement(root, "spiritInfos"); foreach (XElement spiritInfoXML in Tools.GetXmlElements(spiritInfosXML, "spiritInfo")) { int ID = Tools.GetXmlAttributeInt(spiritInfoXML, "ID"); SpiritInfo spInfo = SpiritInfo.parse(spiritInfoXML); spiritInfos.Add(ID, spInfo); } roleWords.Clear(); XElement roleWordsXML = Tools.GetXmlElement(root, "roleWords"); foreach (XElement roleWordXML in Tools.GetXmlElements(roleWordsXML, "roleWord")) { int ID = Tools.GetXmlAttributeInt(roleWordXML, "ID"); string word = Tools.GetXmlAttribute(roleWordXML, "word"); roleWords.Add(ID, word); } roleAttackInfo.Clear(); XElement roleAttackInfosXML = Tools.GetXmlElement(root, "roleAttackInfos"); foreach (XElement roleAttackInfoXML in Tools.GetXmlElements(roleAttackInfosXML, "roleAttackInfo")) { int ID = Tools.GetXmlAttributeInt(roleAttackInfoXML, "ID"); List <BattleWord> blist = BattleWord.parse(Tools.GetXmlElement(roleAttackInfoXML, "battleWords")); roleAttackInfo.Add(ID, blist); } die.Clear(); XElement diesXML = Tools.GetXmlElement(root, "dies"); foreach (XElement dieXML in Tools.GetXmlElements(diesXML, "die")) { int ID = Tools.GetXmlAttributeInt(dieXML, "ID"); die.Add(ID); } }
public void displayBattleEffect(UIHost uihost) { BattleField field = uihost.battleFieldContainer.field; //文字效果 foreach (Spirit sp in field.Spirits) { if (roleWords.ContainsKey(sp.battleID)) { field.ShowSmallDialogBox(sp, roleWords[sp.battleID], 1.0); } if (roleAttackInfo.ContainsKey(sp.battleID)) { foreach (BattleWord battleWord in roleAttackInfo[sp.battleID]) { sp.AddAttackInfo(battleWord.word, battleWord.color); } } } //人物属性 foreach (Spirit sp in field.Spirits) { if (roles.ContainsKey(sp.battleID)) { sp.Role = roles[sp.battleID]; } if (spiritInfos.ContainsKey(sp.battleID)) { SpiritInfo info = spiritInfos[sp.battleID]; sp.X = info.X; sp.Y = info.Y; sp.FaceRight = info.faceright == 0?false:true; sp.ItemCd = info.itemCD; } sp.Refresh(); } //人物死亡情况 for (int i = 0; i < die.Count; i++) { Spirit sp = null; foreach (Spirit spirit in uihost.battleFieldContainer.field.Spirits) { if (spirit.battleID == die[i]) { sp = spirit; break; } } if (sp != null) { sp.Hp = 0; sp.Remove(); uihost.battleFieldContainer.field.Spirits.Remove(sp); } } }