/// <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); }