ShopScanner.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GFGGame;
  5. namespace GFGEditor
  6. {
  7. public class ShopScanner
  8. {
  9. // private static string[] _shopItemType = new string[] { "推荐", "发型", "连衣裙", "内搭", "上衣", "下装", "外套", "袜子", "鞋子", "饰品" };
  10. private static string[] _shopItemType = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  11. //[背景,人物,道具,边框,滤镜]
  12. private static string[] _galleryShopItemType = new string[] { "0", "1", "2", "3", "4" };
  13. public static void StartScan()
  14. {
  15. WriteClothingShop();
  16. WriteCJShop();
  17. WriteCJAShop();
  18. WriteGalleryShop();
  19. }
  20. public static void WriteClothingShop()
  21. {
  22. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  23. SQLiteHelper.Instance.OpenConnection();
  24. try
  25. {
  26. string typeIndex = "";
  27. int itemId;
  28. int id;
  29. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgClothingArray");
  30. while (reader.Read())
  31. {
  32. typeIndex = reader["_typeIndex"].ToString();
  33. itemId = int.Parse(reader["_itemId"].ToString());
  34. id = int.Parse(reader["_id"].ToString());
  35. int count;
  36. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  37. {
  38. count = Array.IndexOf(_shopItemType, typeIndex);
  39. }
  40. else
  41. {
  42. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  43. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  44. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  45. {
  46. count = Array.IndexOf(_shopItemType, itemType);
  47. }
  48. else
  49. {
  50. count = _shopItemType.Length - 1;
  51. }
  52. }
  53. _typeIndexDic.Add(id, count.ToString());
  54. }
  55. }
  56. catch (System.Exception e)
  57. {
  58. ET.Log.Error(e);
  59. }
  60. finally
  61. {
  62. SQLiteHelper.Instance.CloseConnection();
  63. }
  64. SQLiteHelper.Instance.OpenConnection();
  65. try
  66. {
  67. ICollection keys = _typeIndexDic.Keys;
  68. foreach (int key in keys)
  69. {
  70. var names = new string[] { "typeIndex" };
  71. var values = new string[] { "" + _typeIndexDic[key] };
  72. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgClothingArray), names, values, "id", key.ToString());
  73. }
  74. }
  75. catch (Exception e)
  76. {
  77. ET.Log.Error(e.ToString());
  78. }
  79. finally
  80. {
  81. SQLiteHelper.Instance.CloseConnection();
  82. }
  83. }
  84. public static void WriteCJShop()
  85. {
  86. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  87. SQLiteHelper.Instance.OpenConnection();
  88. try
  89. {
  90. string typeIndex = "";
  91. int itemId;
  92. int id;
  93. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJArray");
  94. while (reader.Read())
  95. {
  96. typeIndex = reader["_typeIndex"].ToString();
  97. itemId = int.Parse(reader["_itemId"].ToString());
  98. id = int.Parse(reader["_id"].ToString());
  99. int count;
  100. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  101. {
  102. count = Array.IndexOf(_shopItemType, typeIndex);
  103. }
  104. else
  105. {
  106. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  107. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  108. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  109. {
  110. count = Array.IndexOf(_shopItemType, itemType);
  111. }
  112. else
  113. {
  114. count = _shopItemType.Length - 1;
  115. }
  116. }
  117. _typeIndexDic.Add(id, count.ToString());
  118. }
  119. }
  120. catch (System.Exception e)
  121. {
  122. ET.Log.Error(e);
  123. }
  124. finally
  125. {
  126. SQLiteHelper.Instance.CloseConnection();
  127. }
  128. SQLiteHelper.Instance.OpenConnection();
  129. try
  130. {
  131. ICollection keys = _typeIndexDic.Keys;
  132. foreach (int key in keys)
  133. {
  134. var names = new string[] { "typeIndex" };
  135. var values = new string[] { "" + _typeIndexDic[key] };
  136. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJArray), names, values, "id", key.ToString());
  137. }
  138. }
  139. catch (Exception e)
  140. {
  141. ET.Log.Error(e.ToString());
  142. }
  143. finally
  144. {
  145. SQLiteHelper.Instance.CloseConnection();
  146. }
  147. }
  148. public static void WriteCJAShop()
  149. {
  150. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  151. SQLiteHelper.Instance.OpenConnection();
  152. try
  153. {
  154. string typeIndex = "";
  155. int itemId;
  156. int id;
  157. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJAArray");
  158. while (reader.Read())
  159. {
  160. typeIndex = reader["_typeIndex"].ToString();
  161. itemId = int.Parse(reader["_itemId"].ToString());
  162. id = int.Parse(reader["_id"].ToString());
  163. int count;
  164. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  165. {
  166. count = Array.IndexOf(_shopItemType, typeIndex);
  167. }
  168. else
  169. {
  170. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  171. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  172. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  173. {
  174. count = Array.IndexOf(_shopItemType, itemType);
  175. }
  176. else
  177. {
  178. count = _shopItemType.Length - 1;
  179. }
  180. }
  181. _typeIndexDic.Add(id, count.ToString());
  182. }
  183. }
  184. catch (System.Exception e)
  185. {
  186. ET.Log.Error(e);
  187. }
  188. finally
  189. {
  190. SQLiteHelper.Instance.CloseConnection();
  191. }
  192. SQLiteHelper.Instance.OpenConnection();
  193. try
  194. {
  195. ICollection keys = _typeIndexDic.Keys;
  196. foreach (int key in keys)
  197. {
  198. var names = new string[] { "typeIndex" };
  199. var values = new string[] { "" + _typeIndexDic[key] };
  200. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJAArray), names, values, "id", key.ToString());
  201. }
  202. }
  203. catch (Exception e)
  204. {
  205. ET.Log.Error(e.ToString());
  206. }
  207. finally
  208. {
  209. SQLiteHelper.Instance.CloseConnection();
  210. }
  211. }
  212. public static void WriteGalleryShop()
  213. {
  214. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  215. SQLiteHelper.Instance.OpenConnection();
  216. try
  217. {
  218. string typeIndex = "";
  219. int itemId;
  220. int id;
  221. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgGalleryArray");
  222. while (reader.Read())
  223. {
  224. typeIndex = reader["_typeIndex"].ToString();
  225. itemId = int.Parse(reader["_itemId"].ToString());
  226. id = int.Parse(reader["_id"].ToString());
  227. int count = 2;
  228. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  229. if (itemCfg.itemType == ConstItemType.DRESS_UP)
  230. {
  231. if (itemCfg.subType == ConstDressUpItemType.BEI_JING)
  232. {
  233. count = 0;//背景
  234. }
  235. else
  236. {
  237. count = 2;//道具
  238. }
  239. }
  240. else if (itemCfg.itemType == ConstItemType.PHOTOGRAPH)
  241. {
  242. if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_NPC)
  243. {
  244. count = 1;//人物
  245. }
  246. else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_BOREDR)
  247. {
  248. count = 3;//npc
  249. }
  250. else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_EFFECT)
  251. {
  252. count = 4;//滤镜
  253. }
  254. }
  255. _typeIndexDic.Add(id, count.ToString());
  256. }
  257. }
  258. catch (System.Exception e)
  259. {
  260. ET.Log.Error(e);
  261. }
  262. finally
  263. {
  264. SQLiteHelper.Instance.CloseConnection();
  265. }
  266. SQLiteHelper.Instance.OpenConnection();
  267. try
  268. {
  269. ICollection keys = _typeIndexDic.Keys;
  270. foreach (int key in keys)
  271. {
  272. var names = new string[] { "typeIndex" };
  273. var values = new string[] { "" + _typeIndexDic[key] };
  274. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgGalleryArray), names, values, "id", key.ToString());
  275. }
  276. }
  277. catch (Exception e)
  278. {
  279. ET.Log.Error(e.ToString());
  280. }
  281. finally
  282. {
  283. SQLiteHelper.Instance.CloseConnection();
  284. }
  285. }
  286. }
  287. }