// 从XML中载入卡牌模板信息 public void LoadCardFromXML() { Card InitCard = new Card(); InitCard.SetMainGameController(MainGameController); CardLoader NewCardLoader = new CardLoader(); string filePath = Application.dataPath + "/Resources/Card.xml"; if (File.Exists(filePath)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filePath); XmlNodeList node = xmlDoc.SelectSingleNode("Card").ChildNodes; foreach (XmlElement CardInfo in node) { Card NewCard = null; foreach (XmlElement CardInfoItem in CardInfo.ChildNodes) { if (CardInfoItem.Name == "CardType") { NewCard = NewCardLoader.GetNewCardByType(CardInfoItem.InnerText); } else if (CardInfoItem.Name == "CardSubInfo") { NewCard.LoadInfoFromXML(CardInfoItem); } } AddCard(NewCard); } } }