Example #1
0
    public void OnFindButtonClick()
    {
        string keyWord  = keyWordInputField.text;
        int    cardType = StaticMethod.ChangeCardType(cardTypeDropdown.captionText.text);
        int    cardRace = StaticMethod.ChangeCardRace(cardRaceDropdown.captionText.text);
        int    cardAttr = StaticMethod.ChangeCardAttr(cardAttrDropdown.captionText.text);

        string str       = cardLevelDropdown.captionText.text;
        int    cardLevel = 0;

        if (str != "N/A")
        {
            str = str.Replace("星", "");

            cardLevel = int.Parse(str);
        }
        if (!ComVal.isMonster(cardType))
        {
            if (cardRace != 0 || cardAttr != 0 || cardLevel != 0)
            {
                return;
            }
        }
        editUI.FindCard(cardType, cardAttr, cardRace, cardLevel, keyWord);
    }
Example #2
0
    /// <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;
        }
    }