ExcelChecker.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. using GFGGame;
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. using System;
  5. namespace GFGEditor
  6. {
  7. /// <summary>
  8. /// 配置表检查器:在有限范围内检查表格间关联的数据是否合法,并打印非法数据
  9. /// </summary>
  10. public class ExcelChecker
  11. {
  12. public static void StartCheck()
  13. {
  14. CheckLuckyBoxCfg();
  15. CheckBonusListCfg();
  16. CheckDropOutCfg();
  17. CheckStoryChapterCfg();
  18. CheckStoryLevelCfg();
  19. CheckStoryFightCfg();
  20. CheckClothingShopCfg();
  21. CheckSuitCfg();
  22. CheckSuitGuideMenuCfg();
  23. CheckSuitSyntheticMenuCfg();
  24. CheckSuitSyntheticCfg();
  25. CheckClothingSyntheticCfg();
  26. CheckItemCfg();
  27. CheckCardStarCfg();
  28. CheckCardStoryCfg();
  29. }
  30. private static void CheckLuckyBoxCfg()
  31. {
  32. LuckyBoxCfgArray cfgArray = LuckyBoxCfgArray.Instance;
  33. LuckyBoxCfg[] dataArray = cfgArray.dataArray;
  34. foreach(LuckyBoxCfg boxCfg in dataArray)
  35. {
  36. CheckItemIdExist(boxCfg.costID, "抽奖LuckyBoxCfg.costID");
  37. foreach(int valueInt in boxCfg.bonusShowArr)
  38. {
  39. CheckBonusExist(valueInt, "抽奖LuckyBoxCfg.bonusShow");
  40. }
  41. }
  42. }
  43. private static void CheckBonusListCfg()
  44. {
  45. BonusListCfgArray cfgArray = BonusListCfgArray.Instance;
  46. BonusListCfg[] dataArray = cfgArray.dataArray;
  47. foreach(BonusListCfg cfg in dataArray)
  48. {
  49. foreach(int[] values in cfg.bonusListArr)
  50. {
  51. CheckItemIdExist(values[0], "抽奖BonusListCfg.bonusList");
  52. }
  53. }
  54. }
  55. private static void CheckDropOutCfg()
  56. {
  57. DropOutCfgArray cfgArray = DropOutCfgArray.Instance;
  58. DropOutCfg[] dataArray = cfgArray.dataArray;
  59. foreach(DropOutCfg cfg in dataArray)
  60. {
  61. if(cfg.item >= 10000000)//掉落id
  62. {
  63. CheckDropOutExist(cfg.item, "掉落DropOutCfg.item");
  64. }
  65. else
  66. {
  67. CheckItemIdExist(cfg.item, "掉落DropOutCfg.item");
  68. }
  69. }
  70. }
  71. private static void CheckStoryChapterCfg()
  72. {
  73. StoryChapterCfgArray cfgArray = StoryChapterCfgArray.Instance;
  74. StoryChapterCfg[] dataArray = cfgArray.dataArray;
  75. foreach(StoryChapterCfg cfg in dataArray)
  76. {
  77. CheckItemsExist(cfg.bonus1Arr, "剧情副本StoryChapterCfg.bonus1");
  78. CheckItemsExist(cfg.bonus2Arr, "剧情副本StoryChapterCfg.bonus2");
  79. CheckItemsExist(cfg.bonus3Arr, "剧情副本StoryChapterCfg.bonus3");
  80. }
  81. }
  82. private static void CheckStoryLevelCfg()
  83. {
  84. StoryLevelCfgArray cfgArray = StoryLevelCfgArray.Instance;
  85. StoryLevelCfg[] dataArray = cfgArray.dataArray;
  86. foreach(StoryLevelCfg cfg in dataArray)
  87. {
  88. CheckItemsExist(cfg.bonusOnceArr, "剧情副本StoryLevelCfg.bonusOnce");
  89. CheckStoryDialogExist(cfg.storyStartID, "剧情副本StoryLevelCfg.storyStartID");
  90. CheckStoryFightExist(cfg.fightID, "剧情副本StoryLevelCfg.fightID");
  91. }
  92. }
  93. private static void CheckStoryFightCfg()
  94. {
  95. StoryFightCfgArray cfgArray = StoryFightCfgArray.Instance;
  96. StoryFightCfg[] dataArray = cfgArray.dataArray;
  97. foreach(StoryFightCfg cfg in dataArray)
  98. {
  99. if(cfg.needSuitId > 0)
  100. {
  101. CheckSuitExist(cfg.needSuitId, "剧情副本StoryFightCfg.needSuitId");
  102. }
  103. else if(cfg.needItemId > 0)
  104. {
  105. CheckItemIdExist(cfg.needItemId, "剧情副本StoryFightCfg.needItemId");
  106. }
  107. CheckItemsExist(cfg.bonusBaseArr, "剧情副本StoryFightCfg.bonusBase");
  108. foreach(int value in cfg.bonusRandomArr)
  109. {
  110. CheckDropOutExist(value, "剧情副本StoryFightCfg.bonusRandom");
  111. }
  112. }
  113. }
  114. private static void CheckClothingShopCfg()
  115. {
  116. ClothingShopCfgArray cfgArray = ClothingShopCfgArray.Instance;
  117. ClothingShopCfg[] dataArray = cfgArray.dataArray;
  118. foreach(ClothingShopCfg cfg in dataArray)
  119. {
  120. CheckItemIdExist(cfg.itemID, "商城ClothingShopCfg.itemID");
  121. CheckItemIdExist(cfg.costID, "商城ClothingShopCfg.costID");
  122. }
  123. }
  124. private static void CheckSuitCfg()
  125. {
  126. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  127. SuitCfg[] dataArray = cfgArray.dataArray;
  128. foreach(SuitCfg suitCfg in dataArray)
  129. {
  130. CheckItemsExist(suitCfg.partsArr, "套装suitCfg.parts");
  131. CheckItemsExist(suitCfg.partsOptionalArr, "套装suitCfg.partsOptional");
  132. }
  133. }
  134. private static void CheckSuitGuideMenuCfg()
  135. {
  136. SuitGuideMenuCfgArray cfgArray = SuitGuideMenuCfgArray.Instance;
  137. SuitGuideMenuCfg[] dataArray = cfgArray.dataArray;
  138. foreach(SuitGuideMenuCfg cfg in dataArray)
  139. {
  140. if(cfg.suitIds.Length > 0)
  141. {
  142. string[] values = cfg.suitIds.Split(';');
  143. foreach(string value in values)
  144. {
  145. if(value.Length > 0)
  146. {
  147. int valueInt = int.Parse(value);
  148. CheckSuitExist(valueInt, "图鉴SuitGuideMenuCfg.suitIds");
  149. }
  150. }
  151. }
  152. }
  153. }
  154. private static void CheckSuitSyntheticMenuCfg()
  155. {
  156. SuitSyntheticMenuCfgArray cfgArray = SuitSyntheticMenuCfgArray.Instance;
  157. SuitSyntheticMenuCfg[] dataArray = cfgArray.dataArray;
  158. foreach(SuitSyntheticMenuCfg cfg in dataArray)
  159. {
  160. if (cfg.suitIds.Length > 0)
  161. {
  162. string[] values = cfg.suitIds.Split(';');
  163. foreach (string value in values)
  164. {
  165. int valueInt = int.Parse(value);
  166. CheckSuitExist(valueInt, "合成SuitSyntheticMenuCfg.suitIds");
  167. CheckSuitSyntheticCfgExist(valueInt, "合成SuitSyntheticMenuCfg.suitIds");
  168. CheckSuitClothingSyntheticCfgExist(valueInt, "合成SuitSyntheticMenuCfg.suitIds");
  169. }
  170. }
  171. }
  172. }
  173. private static void CheckSuitSyntheticCfg()
  174. {
  175. SuitSyntheticCfgArray cfgArray = SuitSyntheticCfgArray.Instance;
  176. SuitSyntheticCfg[] dataArray = cfgArray.dataArray;
  177. foreach(SuitSyntheticCfg cfg in dataArray)
  178. {
  179. CheckStoryLevelCfgExist(cfg.storyLevelId, "合成SuitSyntheticCfg.storyLevelId");
  180. CheckSuitExist(cfg.preSuitId, "合成SuitSyntheticCfg.preSuitId");
  181. CheckItemsExist(cfg.boxBonusArr, "合成SuitSyntheticCfg.boxBonus");
  182. }
  183. }
  184. private static void CheckClothingSyntheticCfg()
  185. {
  186. ClothingSyntheticCfgArray cfgArray = ClothingSyntheticCfgArray.Instance;
  187. ClothingSyntheticCfg[] dataArray = cfgArray.dataArray;
  188. foreach(ClothingSyntheticCfg cfg in dataArray)
  189. {
  190. CheckItemIdExist(cfg.costID, "合成ClothingSyntheticCfg.costID");
  191. CheckItemsExist(cfg.materiars, "合成ClothingSyntheticCfg.materiars");
  192. }
  193. }
  194. private static void CheckItemCfg()
  195. {
  196. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  197. ItemCfg[] dataArray = cfgArray.dataArray;
  198. foreach(ItemCfg cfg in dataArray)
  199. {
  200. if (cfg.resLayer1 == 0 && cfg.resLayer2 == 0 && ItemUtilCS.IsDressUpItem(cfg.id))
  201. {
  202. throw (new Exception("物品" + cfg.id + "没有配置显示层"));
  203. }
  204. }
  205. }
  206. //=====================================================================================================
  207. private static void CheckItemIdExist(int id, string keyName)
  208. {
  209. if(id > 0)
  210. {
  211. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  212. ItemCfg itemCfg = cfgArray.GetCfg(id);
  213. if(itemCfg == null)
  214. {
  215. Debug.LogErrorFormat("{0}配置的物品{1}不存在", new object[]{keyName, id} );
  216. }
  217. }
  218. }
  219. private static void CheckItemsExist(string itemsStr, string keyName)
  220. {
  221. string[] itemInfos = itemsStr.Split(';');
  222. foreach(string itemInfo in itemInfos)
  223. {
  224. if(itemInfo.Length > 0)
  225. {
  226. string[] itemValues = itemInfo.Split('*');
  227. CheckItemIdExist(int.Parse(itemValues[0]), keyName);
  228. }
  229. }
  230. }
  231. private static void CheckItemsExist(int[] items, string keyName)
  232. {
  233. foreach (int itemId in items)
  234. {
  235. CheckItemIdExist(itemId, keyName);
  236. }
  237. }
  238. private static void CheckItemsExist(int[][] items, string keyName)
  239. {
  240. foreach (int[] itemInfo in items)
  241. {
  242. CheckItemIdExist(itemInfo[0], keyName);
  243. }
  244. }
  245. private static void CheckBonusExist(int id, string keyName)
  246. {
  247. BonusListCfgArray cfgArray = BonusListCfgArray.Instance;
  248. BonusListCfg cfg = cfgArray.GetCfg(id);
  249. if(cfg == null)
  250. {
  251. Debug.LogErrorFormat("{0}配置的奖励{1}不存在", new object[]{keyName, id} );
  252. }
  253. }
  254. private static void CheckStoryDialogExist(string id, string keyName)
  255. {
  256. if(id.Length > 0)
  257. {
  258. StoryDialogCfgArray cfgArray = StoryDialogCfgArray.Instance;
  259. StoryDialogCfg[] cfg = cfgArray.GetCfgs(id);
  260. if(cfg == null && cfg.Length > 0)
  261. {
  262. Debug.LogErrorFormat("{0}配置的对话{1}不存在", new object[]{keyName, id} );
  263. }
  264. }
  265. }
  266. private static void CheckStoryFightExist(string id, string keyName)
  267. {
  268. if(id.Length > 0)
  269. {
  270. StoryFightCfgArray cfgArray = StoryFightCfgArray.Instance;
  271. StoryFightCfg cfg = cfgArray.GetCfg(id);
  272. if(cfg == null)
  273. {
  274. Debug.LogErrorFormat("{0}配置的战斗{1}不存在", new object[]{keyName, id} );
  275. }
  276. }
  277. }
  278. private static void CheckDropOutExist(int id, string keyName)
  279. {
  280. var arr = DropOutCfgArray.Instance.GetCfgs(id);
  281. List<DropOutCfg> dropOutCfgs = new List<DropOutCfg>(arr);
  282. if(dropOutCfgs == null || dropOutCfgs.Count <= 0)
  283. {
  284. Debug.LogErrorFormat("{0}配置的掉落{1}不存在", new object[]{keyName, id} );
  285. }
  286. }
  287. private static void CheckSuitExist(int id, string keyName)
  288. {
  289. if(id > 0)
  290. {
  291. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  292. SuitCfg cfg = cfgArray.GetCfg(id);
  293. if(cfg == null)
  294. {
  295. Debug.LogErrorFormat("{0}配置的套装{1}不存在", new object[]{keyName, id} );
  296. }
  297. }
  298. }
  299. private static void CheckSuitSyntheticCfgExist(int id, string keyName)
  300. {
  301. if(id > 0)
  302. {
  303. SuitSyntheticCfgArray cfgArray = SuitSyntheticCfgArray.Instance;
  304. SuitSyntheticCfg cfg = cfgArray.GetCfg(id);
  305. if (cfg == null)
  306. {
  307. Debug.LogFormat("{0}配置的套装{1}没有对应的合成解锁配置", new object[] { keyName, id });
  308. }
  309. }
  310. }
  311. private static void CheckSuitClothingSyntheticCfgExist(int id, string keyName)
  312. {
  313. if (id > 0)
  314. {
  315. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  316. SuitCfg cfg = cfgArray.GetCfg(id);
  317. int[] itemInfos = cfg.partsArr;
  318. foreach (int itemId in itemInfos)
  319. {
  320. keyName = string.Format("{0}配置的套装{1}必含部件", keyName, id);
  321. CheckClothingSyntheticCfgExist(itemId, keyName);
  322. }
  323. }
  324. }
  325. private static void CheckClothingSyntheticCfgExist(int id, string keyName)
  326. {
  327. if(id > 0)
  328. {
  329. ClothingSyntheticCfgArray cfgArray = ClothingSyntheticCfgArray.Instance;
  330. ClothingSyntheticCfg cfg = cfgArray.GetCfg(id);
  331. if (cfg == null)
  332. {
  333. Debug.LogErrorFormat("{0}配置的服装{1}没有对应的合成消耗配置", new object[] { keyName, id });
  334. }
  335. }
  336. }
  337. private static void CheckStoryLevelCfgExist(string id, string keyName)
  338. {
  339. if(id.Length > 0)
  340. {
  341. StoryLevelCfgArray cfgArray = StoryLevelCfgArray.Instance;
  342. StoryLevelCfg cfg = cfgArray.GetCfg(id);
  343. if(cfg == null)
  344. {
  345. Debug.LogErrorFormat("{0}配置的关卡{1}不存在", new object[] { keyName, id });
  346. }
  347. }
  348. }
  349. private static void CheckCardStarCfg()
  350. {
  351. CardStarCfgArray cfgArray = CardStarCfgArray.Instance;
  352. CardStarCfg [] dataArray = cfgArray.dataArray;
  353. foreach (CardStarCfg cfg in dataArray)
  354. {
  355. CheckItemsExist(cfg.materiarsArr, "卡牌CardStarCfg.materiars");
  356. }
  357. }
  358. private static void CheckCardStoryCfg()
  359. {
  360. CardStoryCfgArray cfgArray = CardStoryCfgArray.Instance;
  361. CardStoryCfg[] dataArray = cfgArray.dataArray;
  362. foreach (CardStoryCfg cfg in dataArray)
  363. {
  364. CheckStoryDialogExist(cfg.storyStartID, "卡牌CardStoryCfg.storyStartID");
  365. }
  366. }
  367. }
  368. }