ExcelChecker.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. List<ShopCfg> dataArray = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.FU_ZHUANG_DIAN, ConstStoreSubId.FU_ZHUANG_DIAN);
  114. foreach (ShopCfg cfg in dataArray)
  115. {
  116. CheckItemIdExist(cfg.itemId, "商城ClothingShopCfg.itemID");
  117. CheckItemIdExist(cfg.costId, "商城ClothingShopCfg.costID");
  118. }
  119. }
  120. private static void CheckSuitCfg()
  121. {
  122. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  123. SuitCfg[] dataArray = cfgArray.dataArray;
  124. foreach (SuitCfg suitCfg in dataArray)
  125. {
  126. CheckItemsExist(suitCfg.partsArr, "套装suitCfg.parts");
  127. CheckItemsExist(suitCfg.partsOptionalArr, "套装suitCfg.partsOptional");
  128. }
  129. }
  130. private static void CheckSuitGuideMenuCfg()
  131. {
  132. SuitGuideMenuCfgArray cfgArray = SuitGuideMenuCfgArray.Instance;
  133. SuitGuideMenuCfg[] dataArray = cfgArray.dataArray;
  134. foreach (SuitGuideMenuCfg cfg in dataArray)
  135. {
  136. if (cfg.suitIds.Length > 0)
  137. {
  138. string[] values = cfg.suitIds.Split(';');
  139. foreach (string value in values)
  140. {
  141. if (value.Length > 0)
  142. {
  143. int valueInt = int.Parse(value);
  144. CheckSuitExist(valueInt, "图鉴SuitGuideMenuCfg.suitIds");
  145. }
  146. }
  147. }
  148. }
  149. }
  150. private static void CheckClothingSyntheticCfg()
  151. {
  152. //ClothingSyntheticCfgArray cfgArray = ClothingSyntheticCfgArray.Instance;
  153. //ClothingSyntheticCfg[] dataArray = cfgArray.dataArray;
  154. //foreach(ClothingSyntheticCfg cfg in dataArray)
  155. //{
  156. // CheckItemIdExist(cfg.costID, "合成ClothingSyntheticCfg.costID");
  157. // CheckItemsExist(cfg.materiarsArr, "合成ClothingSyntheticCfg.materiars");
  158. //}
  159. }
  160. private static void CheckItemCfg()
  161. {
  162. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  163. ItemCfg[] dataArray = cfgArray.dataArray;
  164. foreach (ItemCfg cfg in dataArray)
  165. {
  166. if (!string.IsNullOrEmpty(cfg.resLayer1) && !string.IsNullOrEmpty(cfg.resLayer2) && !string.IsNullOrEmpty(cfg.resLayer3) && ItemUtilCS.IsDressUpItem(cfg.id))
  167. {
  168. ET.Log.Error(new Exception("物品" + cfg.id + "没有配置显示层"));
  169. }
  170. CheckClothingSyntheticCfgExist(cfg);
  171. }
  172. }
  173. //=====================================================================================================
  174. private static void CheckItemIdExist(int id, string keyName)
  175. {
  176. if (id > 0)
  177. {
  178. ItemCfgArray cfgArray = ItemCfgArray.Instance;
  179. ItemCfg itemCfg = cfgArray.GetCfg(id);
  180. if (itemCfg == null)
  181. {
  182. Debug.LogErrorFormat("{0}配置的物品{1}不存在", new object[] { keyName, id });
  183. }
  184. }
  185. }
  186. private static void CheckItemsExist(string itemsStr, string keyName)
  187. {
  188. string[] itemInfos = itemsStr.Split(';');
  189. foreach (string itemInfo in itemInfos)
  190. {
  191. if (itemInfo.Length > 0)
  192. {
  193. string[] itemValues = itemInfo.Split('*');
  194. CheckItemIdExist(int.Parse(itemValues[0]), keyName);
  195. }
  196. }
  197. }
  198. private static void CheckItemsExist(int[] items, string keyName)
  199. {
  200. foreach (int itemId in items)
  201. {
  202. CheckItemIdExist(itemId, keyName);
  203. }
  204. }
  205. private static void CheckItemsExist(int[][] items, string keyName)
  206. {
  207. foreach (int[] itemInfo in items)
  208. {
  209. CheckItemIdExist(itemInfo[0], keyName);
  210. }
  211. }
  212. private static void CheckBonusExist(int id, string keyName)
  213. {
  214. BonusListCfgArray cfgArray = BonusListCfgArray.Instance;
  215. BonusListCfg cfg = cfgArray.GetCfg(id);
  216. if (cfg == null)
  217. {
  218. Debug.LogErrorFormat("{0}配置的奖励{1}不存在", new object[] { keyName, id });
  219. }
  220. }
  221. private static void CheckStoryDialogExist(string id, string keyName)
  222. {
  223. if (id.Length > 0)
  224. {
  225. StoryDialogCfgArray cfgArray = StoryDialogCfgArray.Instance;
  226. List<StoryDialogCfg> cfg = cfgArray.GetCfgsByid(id);
  227. if (cfg == null && cfg.Count > 0)
  228. {
  229. Debug.LogErrorFormat("{0}配置的对话{1}不存在", new object[] { keyName, id });
  230. }
  231. }
  232. }
  233. private static void CheckStoryFightExist(string id, string keyName)
  234. {
  235. if (id.Length > 0)
  236. {
  237. StoryFightCfgArray cfgArray = StoryFightCfgArray.Instance;
  238. StoryFightCfg cfg = cfgArray.GetCfg(id);
  239. if (cfg == null)
  240. {
  241. Debug.LogErrorFormat("{0}配置的战斗{1}不存在", new object[] { keyName, id });
  242. }
  243. }
  244. }
  245. private static void CheckDropOutExist(int id, string keyName)
  246. {
  247. var arr = DropOutCfgArray.Instance.GetCfgsByid(id);
  248. List<DropOutCfg> dropOutCfgs = new List<DropOutCfg>(arr);
  249. if (dropOutCfgs == null || dropOutCfgs.Count <= 0)
  250. {
  251. Debug.LogErrorFormat("{0}配置的掉落{1}不存在", new object[] { keyName, id });
  252. }
  253. }
  254. private static void CheckSuitExist(int id, string keyName)
  255. {
  256. if (id > 0)
  257. {
  258. SuitCfgArray cfgArray = SuitCfgArray.Instance;
  259. SuitCfg cfg = cfgArray.GetCfg(id);
  260. if (cfg == null)
  261. {
  262. Debug.LogErrorFormat("{0}配置的套装{1}不存在", new object[] { keyName, id });
  263. }
  264. }
  265. }
  266. private static void CheckClothingSyntheticCfgExist(ItemCfg itemCfg)
  267. {
  268. if (itemCfg.suitId > 0)
  269. {
  270. var suitCfg = SuitCfgArray.Instance.GetCfg(itemCfg.suitId);
  271. if (suitCfg != null && suitCfg.syntheticType > 0)
  272. {
  273. if (itemCfg.syntheticCostID <= 0 || itemCfg.syntheticCostNum <= 0 || itemCfg.syntheticMateriarsArr.Length <= 0)
  274. {
  275. Debug.LogErrorFormat("服装{0}没有对应的合成消耗配置", new object[] { itemCfg.id });
  276. }
  277. }
  278. }
  279. }
  280. private static void CheckStoryLevelCfgExist(int id, string keyName)
  281. {
  282. if (id > 0)
  283. {
  284. StoryLevelCfgArray cfgArray = StoryLevelCfgArray.Instance;
  285. StoryLevelCfg cfg = cfgArray.GetCfg(id);
  286. if (cfg == null)
  287. {
  288. Debug.LogErrorFormat("{0}配置的关卡{1}不存在", new object[] { keyName, id });
  289. }
  290. }
  291. }
  292. private static void CheckCardStarCfg()
  293. {
  294. CardStarCfgArray cfgArray = CardStarCfgArray.Instance;
  295. CardStarCfg[] dataArray = cfgArray.dataArray;
  296. foreach (CardStarCfg cfg in dataArray)
  297. {
  298. CheckItemsExist(cfg.materiarsArr, "卡牌CardStarCfg.materiars");
  299. }
  300. }
  301. private static void CheckCardStoryCfg()
  302. {
  303. CardStoryCfgArray cfgArray = CardStoryCfgArray.Instance;
  304. CardStoryCfg[] dataArray = cfgArray.dataArray;
  305. foreach (CardStoryCfg cfg in dataArray)
  306. {
  307. CheckStoryDialogExist(cfg.storyStartID, "卡牌CardStoryCfg.storyStartID");
  308. }
  309. }
  310. }
  311. }