Exemple #1
0
    /// <summary>
    /// 加载卡组
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public static Deck LoadDeck(string name)
    {
        bool readMain  = false;
        bool readExtra = false;
        // Debug.Log(Application.persistentDataPath + "/" + name);
        Deck         deck = new Deck();
        StreamReader sr   = new StreamReader(Application.streamingAssetsPath + "/" + name + ".ydk");
        // Debug.Log(Application.persistentDataPath);
        string line;

        for (int i = 0; i < 200; i++)
        {
            line = sr.ReadLine();
            if (line == "#main")
            {
                readMain = true;
                continue;
            }
            if (line == "#extra")
            {
                readMain  = false;
                readExtra = true;
                continue;
            }
            if (line == "#end")
            {
                break;
            }
            if (readMain == true)
            {
                Card card = CardFactroy.GenerateCard(line);
                if (card.IsMonster())
                {
                    card.SetMonsterAttribute(card.attribute, card.race, card.level, card.afk, card.def);
                }
                deck.AddCardToMain(card);
            }

            if (readExtra == true)
            {
                Card card = CardFactroy.GenerateCard(line);

                if (card.IsMonster())
                {
                    card.SetMonsterAttribute(card.attribute, card.race, card.level, card.afk, card.def);
                }
                deck.AddCardToExtra(card);
            }
        }
        sr.Close();
        return(deck);
    }
Exemple #2
0
 /// <summary>
 /// 生成卡组
 /// </summary>
 /// <param name="main"></param>
 /// <param name="extra"></param>
 public Deck(string[] main, string[] extra)
 {
     mainDeck = new Group();
     extraDeck = new Group();
     for (int i = 0; i < main.Length; i++)
     {
         Card card = CardFactroy.GenerateCard(main[i]);
         mainDeck.AddCard(card);
     }
     for (int i = 0; i < extra.Length; i++)
     {
         Card card = CardFactroy.GenerateCard(extra[i]);
         extraDeck.AddCard(card);
     }
 }
Exemple #3
0
 public void AddCardToExtra(string id)
 {
     Card card = CardFactroy.GenerateCard(id);
     extraDeck.AddCard(card);
 }
Exemple #4
0
 public void AddCardToMain(string id)
 {
     Card card = CardFactroy.GenerateCard(id);
     mainDeck.AddCard(card);
 }