/// <summary> /// 加载文件中的卡片 /// </summary> /// <param name="path"></param> /// <returns></returns> public async Task <CardDefine[]> loadCards(string path, PlatformCompability platform = null) { platform = platform ?? PlatformCompability.Current; DataSet dataset = platform.SupportExcelReading ? await getManager <ResourceManager>().loadExcelAsDataSet(path, platform) : await getManager <ResourceManager>().loadDataSet(path, platform); if (dataset.Tables.Count < 1) { throw new Exception("空数据集"); } var table = dataset.Tables[0]; List <CardDefine> cards = new List <CardDefine>(); for (int i = 1; i < table.Rows.Count; i++) { try { var datarow = table.Rows[i]; if (datarow.ReadCol("Ignore", false)) { continue; } var card = new GeneratedCardDefine(); card.id = datarow.ReadCol <int>("ID"); card.type = datarow.ReadCol <string>("Type"); card.setProp(nameof(ServantCardDefine.cost), datarow.ReadCol("Cost", 0)); card.setProp(nameof(ServantCardDefine.attack), datarow.ReadCol("Attack", 0)); card.setProp(nameof(ServantCardDefine.life), datarow.ReadCol("Life", 0)); card.setProp(nameof(ServantCardDefine.tags), datarow.ReadCol("Tags", "").Split(',')); card.setProp(nameof(ServantCardDefine.keywords), datarow.ReadCol("Keywords", "").Split(',')); card.setProp(nameof(ServantCardDefine.isToken), datarow.ReadCol("IsToken", false)); card.setProp(nameof(ServantCardDefine.isActive), datarow.ReadCol("IsActive", false)); cards.Add(card); } catch (Exception e) { Debug.LogWarning($"Error when loading {path} (row {i}): " + e); } } return(cards.ToArray()); }
/// <summary> /// 加载文件中的卡片 /// </summary> /// <param name="path"></param> /// <returns></returns> public async Task <CardDefine[]> loadCards(string path, RuntimePlatform?platform = null) { #if UNITY_ANDROID if (platform == null) { platform = RuntimePlatform.Android; } #endif var dataset = platform != RuntimePlatform.Android ? await getManager <ResourceManager>().loadExcelAsDataSet(path, platform) : await getManager <ResourceManager>().loadDataSet(path, platform); if (dataset.Tables.Count < 1) { throw new Exception("空数据集"); } var table = dataset.Tables[0]; List <CardDefine> cards = new List <CardDefine>(); for (int i = 1; i < table.Rows.Count; i++) { var datarow = table.Rows[i]; if (datarow.ReadCol("Ignore", false)) { continue; } var card = new GeneratedCardDefine(); card.id = datarow.ReadCol <int>("ID"); card.type = datarow.ReadCol <string>("Type"); card.setProp(nameof(ServantCardDefine.cost), datarow.ReadCol <int>("Cost", 0)); card.setProp(nameof(ServantCardDefine.attack), datarow.ReadCol <int>("Attack", 0)); card.setProp(nameof(ServantCardDefine.life), datarow.ReadCol <int>("Life", 0)); card.setProp(nameof(ServantCardDefine.tags), datarow.ReadCol <string>("Tags", "").Split(',')); card.setProp(nameof(ServantCardDefine.keywords), datarow.ReadCol <string>("Keywords", "").Split(',')); card.setProp(nameof(ServantCardDefine.isToken), datarow.ReadCol <bool>("IsToken", false)); cards.Add(card); } return(cards.ToArray()); }