internal XmlAnswerExample(XmlCard card, ParentClass parent) : base(parent) { base.m_basePath = m_basePath; this.m_Culture = card.Dictionary.AnswerCulture; Initialize(card, WordType.Sentence); }
internal XmlQuestion(XmlCard card, ParentClass parent) : base(parent) { base.m_basePath = m_basePath; this.m_Culture = card.Dictionary.QuestionCulture; Initialize(card, WordType.Word); }
public void UpdateCardDisplay(params object[] args) { string cardID = (string)args[0]; if (cardID == "0" || cardID == "") { return; } XmlCard card = LoadXml.GetXmlCard(cardID); string star = ""; rawImage.texture = StaticMethod.GetCardPics(cardID, false); effectText.text = card.cardDescribe; nameText.text = "[" + card.cardName.ToString() + "]" + "\n"; nameText.text += "[" + card.cardType + "]"; if (card.IsMonster()) { for (int i = 0; i < card.level; i++) { star = star + "★"; } nameText.text += " " + card.race + "/" + card.attribute + "\n"; nameText.text += "[" + star + "]" + " " + card.afk + "/" + card.def; } }
internal XmlAnswerDistractors(XmlDictionary dic, XmlCard card, ParentClass parent) : base(parent) { base.m_oDictionary = dic; base.m_XPathBasePath = m_XPathBasePath; this.m_Culture = card.Dictionary.AnswerCulture; Initialize(card); }
/// <summary> /// Initializes this instance - reads all cards from the data file. /// </summary> /// <remarks>Documented by Dev03, 2007-08-24</remarks> internal void Initialize() { m_cards.Clear(); foreach (XmlNode card in m_dictionary.SelectNodes(m_basePath)) { XmlCard xmlCard = new XmlCard(m_oDictionary, (XmlElement)card, parent.GetChildParentClass(this)); m_cards.Add(xmlCard); } m_currentId = GetCurrentId(); }
/// <summary> /// Adds the new card to the dictionary. /// </summary> /// <returns>The card.</returns> /// <remarks>Documented by Dev03, 2007-08-30</remarks> public ICard AddNew() { XmlCard newCard = new XmlCard(m_oDictionary, parent.GetChildParentClass(this)); UpdateCurrentId(); newCard.Id = GetNextId(); m_dictionary.DocumentElement.AppendChild(newCard.Xml); m_cards.Add(newCard); newCard.Active = true; PrepareIdNavigator(); return(newCard); }
protected void Initialize(XmlCard card) { m_card = card.Xml; m_Distractors.Clear(); if (m_card[m_XPathBasePath] != null) { foreach (XmlNode distractor in m_card[m_XPathBasePath].SelectNodes(m_XPathDistractor)) { XmlDistractor xmlDistractor = new XmlDistractor(distractor as XmlElement, this.Parent.GetChildParentClass(this)); IWord word = new XmlWord(xmlDistractor.Word, xmlDistractor.Type, false, Parent.GetChildParentClass(this)); AssignWordPropertyChanged(word); m_Distractors.Add(word); } } }
/// <summary> /// Deletes the specified card. /// </summary> /// <param name="card_id">The card id.</param> /// <remarks>Documented by Dev03, 2007-08-30</remarks> public void Delete(int card_id) { //XmlNode nodeToDelete = m_dictionary.SelectSingleNode(m_basePath + String.Format(m_XPathIdFilter, card_id)); //nodeToDelete.ParentNode.RemoveChild(nodeToDelete); System.Diagnostics.Debug.WriteLine("XmlCards.Delete() - start:\t" + DateTime.Now.Ticks); XmlCard cardToDelete = (XmlCard)Get(card_id); cardToDelete.Active = false; //remove from list System.Diagnostics.Debug.WriteLine("XmlCards.Delete() - list:\t" + DateTime.Now.Ticks); m_cards.Remove(cardToDelete as ICard); //remove from DOM System.Diagnostics.Debug.WriteLine("XmlCards.Delete() - dom:\t" + DateTime.Now.Ticks); (cardToDelete as XmlCard).Xml.ParentNode.RemoveChild((cardToDelete as XmlCard).Xml); System.Diagnostics.Debug.WriteLine("XmlCards.Delete() - end:\t" + DateTime.Now.Ticks); }
/// <summary> /// 卡片描述 \n ★ /// </summary> public void SetText(string id) { XmlCard card = LoadXml.GetXmlCard(id); theText.text = ""; theText.text += card.cardName + "\n"; if (card.IsMonster()) { theText.text += card.afk.ToString() + "/" + card.def.ToString() + "\n"; theText.text += card.attribute + "/" + card.race + " " + "★" + card.level.ToString(); } else { theText.text += card.cardType; } }
/// <summary> /// 加载xml 并将其保存在卡片字典中 /// </summary> /// public static void LoadTheXml() { if (isLoad) { return; } CardDic = new Dictionary <string, Card>(); XmlCardDic = new Dictionary <string, XmlCard>(); XmlDocument xmlDoc = new XmlDocument(); TextAsset textAsset = (TextAsset)Resources.Load("Card"); xmlDoc.LoadXml(textAsset.text); XmlNodeList xmlNodeList = xmlDoc.SelectSingleNode("Cards").ChildNodes; foreach (XmlNode node in xmlNodeList) { string cardID = node.Attributes["cardID"].Value; string cardName = node.Attributes["cardName"].Value; string cardDescribe = node.Attributes["cardDescribe"].Value; string str_cardType = node.Attributes["cardType"].Value; int int_cardType = StaticMethod.ChangeCardType(str_cardType); Card card = new Card(cardID, cardName, cardDescribe, int_cardType); XmlCard xmlCard = new XmlCard(cardID, cardName, cardDescribe, str_cardType); if (card.IsMonster()) { int afk = int.Parse(node.Attributes["afk"].Value); int def = int.Parse(node.Attributes["def"].Value); int level = int.Parse(node.Attributes["level"].Value); string str_attribute = node.Attributes["attribute"].Value; int int_attribute = StaticMethod.ChangeCardAttr(str_attribute, cardID); string str_race = node.Attributes["race"].Value; int int_race = StaticMethod.ChangeCardRace(str_race); card.SetMonsterAttribute(int_attribute, int_race, level, afk, def); xmlCard.SetMonsterAttribute(str_attribute, str_race, level, afk, def); } CardDic.Add(cardID, card); XmlCardDic.Add(cardID, xmlCard); // Debug.Log(card.cardName + " " + card.cardType + " " + card.cardDescribe + " " + card.afk + " " + card.level + " " + card.race); //Debug.Log(cardID + cardName); isLoad = true; } }
protected void Initialize(XmlCard card, WordType wordType) { m_oDictionary = card.Dictionary; m_card = card.Xml; if (wordType == WordType.Word) { string[] words; words = Helper.SplitWordList(m_card.SelectSingleNode(m_basePath).InnerText); for (int i = 0; i < words.Length; i++) { AddWord(new XmlWord(words[i], wordType, false, Parent.GetChildParentClass(this))); } } else { string sSentence = m_card.SelectSingleNode(m_basePath).InnerText.Trim(); if (sSentence.Length > 0) { AddWord(new XmlWord(m_card.SelectSingleNode(m_basePath).InnerText, WordType.Sentence, false, Parent.GetChildParentClass(this))); } } }