ExcelChecker.cs 11 KB

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