/// <summary> /// 初始化卡牌列表 /// </summary> void Awake() { //Debug.Log("OnEnable"); completeCardList = LoadJson.LoadJsonFromFile <CardDataList>("/cardListData.json"); for (int i = 0; i < completeCardList.cardCount; i++) { freeCardList.Add(completeCardList.cardList[i]); } //Debug.Log(freeCardList.Count + "awake"); }
void OnEnable() { //Link to the correct DB on enable. CardDataPath is necessarry for the other links string objectPath = EditorPrefs.GetString("CardDataPath"); cardDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CardDataList)) as CardDataList; string atkPath = EditorPrefs.GetString("AttackDatabasePath"); atkDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList; string unitPath = EditorPrefs.GetString("UnitDataPath"); unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList; }
void Start() { List <CardData> freeCardList = new List <CardData>(); CardDataList completeCardList = LoadJson.LoadJsonFromFile <CardDataList>("/cardListData123.json"); for (int i = 0; i < completeCardList.cardCount; i++) { freeCardList.Add(completeCardList.cardList[i]); } GameObject selectCardBoard = Instantiate(selectCardBoardPrefab); selectCardBoard.GetComponent <SelectCardBoardBH>().CreateSelectCardBoard(freeCardList); }
static Startup() { //Get all the database paths setup for the editor string atkPath = "Assets/AttackList.asset"; string unitPath = "Assets/UnitList.asset"; string cardPath = "Assets/CardList.asset"; //Attacks EditorPrefs.SetString("AttackDatabasePath", atkPath); attackDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList; if(attackDataList == null) { Debug.Log("No attack database, creating empty one."); AttackDataList asset = ScriptableObject.CreateInstance<AttackDataList>(); AssetDatabase.CreateAsset(asset, atkPath); AssetDatabase.SaveAssets(); } //Creatures EditorPrefs.SetString("UnitDataPath", unitPath); unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList; if (unitDataList == null) { Debug.Log("No unit database, creating empty one."); UnitDataList asset = ScriptableObject.CreateInstance<UnitDataList>(); AssetDatabase.CreateAsset(asset, unitPath); AssetDatabase.SaveAssets(); } //Cards EditorPrefs.SetString("CardDataPath", cardPath); cardDataList = AssetDatabase.LoadAssetAtPath(cardPath, typeof(CardDataList)) as CardDataList; if(cardDataList == null) { Debug.Log("No card database, creating empty one."); CardDataList asset = ScriptableObject.CreateInstance<CardDataList>(); AssetDatabase.CreateAsset(asset, cardPath); AssetDatabase.SaveAssets(); } }
private CardDataHelper() { using (StreamReader cardDataSR = new StreamReader(Application.dataPath + "/ExcelData/card_data.json")) { string data = cardDataSR.ReadToEnd(); cardDataSR.Close(); data = "{\"data\":" + data + "}"; CardDataList json = JsonMapper.ToObject <CardDataList>(data); // 预处理数据 for (int i = 0; i < json.data.Count; i++) { if (cardDataDict.ContainsKey(json.data[i].Id)) { cardDataDict[json.data[i].Id] = json.data[i]; } else { cardDataDict.Add(json.data[i].Id, json.data[i]); } } } }
void Awake() { Cards = IO.LoadFromJson <CardDataList>(CARD_PATH); Decks = IO.LoadFromJson <DeckDataList>(DECK_PATH); DeckSelections = IO.LoadFromJson <DeckSelectionData>(DECK_SELECTION_PATH); }