ExcelChecker.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. CheckItemCfg();
  24. CheckCardStarCfg();
  25. CheckCardStoryCfg();
  26. }
  27. private static void CheckLuckyBoxCfg()
  28. {
  29. LuckyBoxCfgArray cfgArray = LuckyBoxCfgArray.Instance;
  30. LuckyBoxCfg[] dataArray = cfgArray.dataArray;
  31. foreach (LuckyBoxCfg boxCfg in dataArray)
  32. {
  33. CheckItemIdExist(boxCfg.costID, "抽奖LuckyBoxCfg.costID");
  34. foreach (int valueInt in boxCfg.bonusShowArr)
  35. {
  36. CheckBonusExist(valueInt, "抽奖LuckyBoxCfg.bonusShow");
  37. }
  38. }
  39. }
  40. private static void CheckBonusListCfg()
  41. {
  42. BonusListCfgArray cfgArray = BonusListCfgArray.Instance;
  43. BonusListCfg[] dataArray = cfgArray.dataArray;
  44. foreach (BonusListCfg cfg in dataArray)
  45. {
  46. foreach (int[] values in cfg.bonusListArr)
  47. {
  48. CheckItemIdExist(values[0], "抽奖BonusListCfg.bonusList");
  49. }
  50. }
  51. }
  52. private static void CheckDropOutCfg()
  53. {
  54. DropOutCfgArray cfgArray = DropOutCfgArray.Instance;
  55. DropOutCfg[] dataArray = cfgArray.dataArray;
  56. foreach (DropOutCfg cfg in dataArray)
  57. {
  58. if (cfg.item >= 10000000)//掉落id
  59. {
  60. CheckDropOutExist(cfg.item, "掉落DropOutCfg.item");
  61. }
  62. else
  63. {
  64. CheckItemIdExist(cfg.item, "掉落DropOutCfg.item");
  65. }
  66. }
  67. }
  68. private static void CheckStoryChapterCfg()
  69. {
  70. StoryChapterCfgArray cfgArray = StoryChapterCfgArray.Instance;
  71. StoryChapterCfg[] dataArray = cfgArray.dataArray;
  72. foreach (StoryChapterCfg cfg in dataArray)
  73. {
  74. CheckItemsExist(cfg.bonus1Arr, "剧情副本StoryChapterCfg.bonus1");
  75. CheckItemsExist(cfg.bonus2Arr, "剧情副本StoryChapterCfg.bonus2");
  76. CheckItemsExist(cfg.bonus3Arr, "剧情副本StoryChapterCfg.bonus3");
  77. }
  78. }
  79. private static void CheckStoryLevelCfg()
  80. {
  81. StoryLevelCfgArray cfgArray = StoryLevelCfgArray.Instance;
  82. StoryLevelCfg[] dataArray = cfgArray.dataArray;
  83. foreach (StoryLevelCfg cfg in dataArray)
  84. {
  85. CheckItemsExist(cfg.bonusOnceArr, "剧情副本StoryLevelCfg.bonusOnce");
  86. CheckStoryDialogExist(cfg.storyStartID, "剧情副本StoryLevelCfg.storyStartID");
  87. CheckStoryFightExist(cfg.fightID, "剧情副本StoryLevelCfg.fightID");
  88. }
  89. }
  90. private static void CheckStoryFightCfg()
  91. {
  92. StoryFightCfgArray cfgArray = StoryFightCfgArray.Instance;
  93. StoryFightCfg[] dataArray = cfgArray.dataArray;
  94. foreach (StoryFightCfg cfg in dataArray)
  95. {
  96. if (cfg.needSuitId > 0)
  97. {
  98. CheckSuitExist(cfg.needSuitId, "剧情副本StoryFightCfg.needSuitId");
  99. }
  100. else if (cfg.needItemId > 0)
  101. {
  102. CheckItemIdExist(cfg.needItemId, "剧情副本StoryFightCfg.needItemId");
  103. }
  104. CheckItemsExist(cfg.bonusBaseArr, "剧情副本StoryFightCfg.bonusBase");
  105. foreach (int value in cfg.bonusRandomArr)
  106. {
  107. CheckDropOutExist(value, "剧情副本StoryFightCfg.bonusRandom");
  108. }
  109. }
  110. }
  111. private static void CheckClothingShopCfg()
  112. {
  113. ShopCfgClothingArray cfgArray = ShopCfgClothingArray.Instance;
  114. ShopCfg[] dataArray = cfgArray.dataArray;
  115. foreach (ShopCfg cfg in dataArray)
  116. {
  117. CheckItemIdExist(cfg.itemID, "商城ClothingShopCfg.itemID");
  118. CheckItemIdExist(cfg.costID, "商城ClothingShopCfg.costID");
  119. }
  120. }
  121. private static void CheckSuitCfg()
  122. {
  123. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  124. SuitCfg[] dataArray = cfgArray.dataArray;
  125. foreach (SuitCfg suitCfg in dataArray)
  126. {
  127. CheckItemsExist(suitCfg.partsArr, "套装suitCfg.parts");
  128. CheckItemsExist(suitCfg.partsOptionalArr, "套装suitCfg.partsOptional");
  129. }
  130. }
  131. private static void CheckSuitGuideMenuCfg()
  132. {
  133. SuitGuideMenuCfgArray cfgArray = SuitGuideMenuCfgArray.Instance;
  134. SuitGuideMenuCfg[] dataArray = cfgArray.dataArray;
  135. foreach (SuitGuideMenuCfg cfg in dataArray)
  136. {
  137. if (cfg.suitIds.Length > 0)
  138. {
  139. string[] values = cfg.suitIds.Split(';');
  140. foreach (string value in values)
  141. {
  142. if (value.Length > 0)
  143. {
  144. int valueInt = int.Parse(value);
  145. CheckSuitExist(valueInt, "图鉴SuitGuideMenuCfg.suitIds");
  146. }
  147. }
  148. }
  149. }
  150. }
  151. private static void CheckClothingSyntheticCfg()
  152. {
  153. //ClothingSyntheticCfgArray cfgArray = ClothingSyntheticCfgArray.Instance;
  154. //ClothingSyntheticCfg[] dataArray = cfgArray.dataArray;
  155. //foreach(ClothingSyntheticCfg cfg in dataArray)
  156. //{
  157. // CheckItemIdExist(cfg.costID, "合成ClothingSyntheticCfg.costID");
  158. // CheckItemsExist(cfg.materiarsArr, "合成ClothingSyntheticCfg.materiars");
  159. //}
  160. }
  161. private static void CheckItemCfg()
  162. {
  163. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  164. ItemCfg[] dataArray = cfgArray.dataArray;
  165. foreach (ItemCfg cfg in dataArray)
  166. {
  167. if (!string.IsNullOrEmpty(cfg.resLayer1) && !string.IsNullOrEmpty(cfg.resLayer2) && !string.IsNullOrEmpty(cfg.resLayer3) && ItemUtilCS.IsDressUpItem(cfg.id))
  168. {
  169. ET.Log.Error(new Exception("物品" + cfg.id + "没有配置显示层"));
  170. }
  171. CheckClothingSyntheticCfgExist(cfg);
  172. }
  173. }
  174. //=====================================================================================================
  175. private static void CheckItemIdExist(int id, string keyName)
  176. {
  177. if (id > 0)
  178. {
  179. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  180. ItemCfg itemCfg = cfgArray.GetCfg(id);
  181. if (itemCfg == null)
  182. {
  183. Debug.LogErrorFormat("{0}配置的物品{1}不存在", new object[] { keyName, id });
  184. }
  185. }
  186. }
  187. private static void CheckItemsExist(string itemsStr, string keyName)
  188. {
  189. string[] itemInfos = itemsStr.Split(';');
  190. foreach (string itemInfo in itemInfos)
  191. {
  192. if (itemInfo.Length > 0)
  193. {
  194. string[] itemValues = itemInfo.Split('*');
  195. CheckItemIdExist(int.Parse(itemValues[0]), keyName);
  196. }
  197. }
  198. }
  199. private static void CheckItemsExist(int[] items, string keyName)
  200. {
  201. foreach (int itemId in items)
  202. {
  203. CheckItemIdExist(itemId, keyName);
  204. }
  205. }
  206. private static void CheckItemsExist(int[][] items, string keyName)
  207. {
  208. foreach (int[] itemInfo in items)
  209. {
  210. CheckItemIdExist(itemInfo[0], keyName);
  211. }
  212. }
  213. private static void CheckBonusExist(int id, string keyName)
  214. {
  215. BonusListCfgArray cfgArray = BonusListCfgArray.Instance;
  216. BonusListCfg cfg = cfgArray.GetCfg(id);
  217. if (cfg == null)
  218. {
  219. Debug.LogErrorFormat("{0}配置的奖励{1}不存在", new object[] { keyName, id });
  220. }
  221. }
  222. private static void CheckStoryDialogExist(string id, string keyName)
  223. {
  224. if (id.Length > 0)
  225. {
  226. StoryDialogCfgArray cfgArray = StoryDialogCfgArray.Instance;
  227. List<StoryDialogCfg> cfg = cfgArray.GetCfgs(id);
  228. if (cfg == null && cfg.Count > 0)
  229. {
  230. Debug.LogErrorFormat("{0}配置的对话{1}不存在", new object[] { keyName, id });
  231. }
  232. }
  233. }
  234. private static void CheckStoryFightExist(string id, string keyName)
  235. {
  236. if (id.Length > 0)
  237. {
  238. StoryFightCfgArray cfgArray = StoryFightCfgArray.Instance;
  239. StoryFightCfg cfg = cfgArray.GetCfg(id);
  240. if (cfg == null)
  241. {
  242. Debug.LogErrorFormat("{0}配置的战斗{1}不存在", new object[] { keyName, id });
  243. }
  244. }
  245. }
  246. private static void CheckDropOutExist(int id, string keyName)
  247. {
  248. var arr = DropOutCfgArray.Instance.GetCfgs(id);
  249. List<DropOutCfg> dropOutCfgs = new List<DropOutCfg>(arr);
  250. if (dropOutCfgs == null || dropOutCfgs.Count <= 0)
  251. {
  252. Debug.LogErrorFormat("{0}配置的掉落{1}不存在", new object[] { keyName, id });
  253. }
  254. }
  255. private static void CheckSuitExist(int id, string keyName)
  256. {
  257. if (id > 0)
  258. {
  259. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  260. SuitCfg cfg = cfgArray.GetCfg(id);
  261. if (cfg == null)
  262. {
  263. Debug.LogErrorFormat("{0}配置的套装{1}不存在", new object[] { keyName, id });
  264. }
  265. }
  266. }
  267. private static void CheckClothingSyntheticCfgExist(ItemCfg itemCfg)
  268. {
  269. if (itemCfg.suitId > 0)
  270. {
  271. var suitCfg = SuitCfgArray.Instance.GetCfg(itemCfg.suitId);
  272. if (suitCfg != null && suitCfg.syntheticType > 0)
  273. {
  274. if (itemCfg.syntheticCostID <= 0 || itemCfg.syntheticCostNum <= 0 || itemCfg.syntheticMateriarsArr.Length <= 0)
  275. {
  276. Debug.LogErrorFormat("服装{0}没有对应的合成消耗配置", new object[] { itemCfg.id });
  277. }
  278. }
  279. }
  280. }
  281. private static void CheckStoryLevelCfgExist(int id, string keyName)
  282. {
  283. if (id > 0)
  284. {
  285. StoryLevelCfgArray cfgArray = StoryLevelCfgArray.Instance;
  286. StoryLevelCfg cfg = cfgArray.GetCfg(id);
  287. if (cfg == null)
  288. {
  289. Debug.LogErrorFormat("{0}配置的关卡{1}不存在", new object[] { keyName, id });
  290. }
  291. }
  292. }
  293. private static void CheckCardStarCfg()
  294. {
  295. CardStarCfgArray cfgArray = CardStarCfgArray.Instance;
  296. CardStarCfg[] dataArray = cfgArray.dataArray;
  297. foreach (CardStarCfg cfg in dataArray)
  298. {
  299. CheckItemsExist(cfg.materiarsArr, "卡牌CardStarCfg.materiars");
  300. }
  301. }
  302. private static void CheckCardStoryCfg()
  303. {
  304. CardStoryCfgArray cfgArray = CardStoryCfgArray.Instance;
  305. CardStoryCfg[] dataArray = cfgArray.dataArray;
  306. foreach (CardStoryCfg cfg in dataArray)
  307. {
  308. CheckStoryDialogExist(cfg.storyStartID, "卡牌CardStoryCfg.storyStartID");
  309. }
  310. }
  311. }
  312. }