ShopScanner.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. try
  24. {
  25. List<ShopCfg> clothingShopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.FU_ZHUANG_DIAN, ConstStoreSubId.FU_ZHUANG_DIAN);
  26. string typeIndex = "";
  27. int itemId;
  28. int id;
  29. int index = 0;
  30. while (index < clothingShopCfgs.Count)
  31. {
  32. typeIndex = clothingShopCfgs[index].typeIndex.ToString();// reader["_typeIndex"].ToString();
  33. itemId = clothingShopCfgs[index].itemId;// int.Parse(reader["_itemId"].ToString());
  34. id = clothingShopCfgs[index].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. index++;
  55. }
  56. }
  57. catch (Exception e)
  58. {
  59. ET.Log.Error(e.ToString());
  60. }
  61. finally
  62. {
  63. SQLiteHelper.Instance.CloseConnection();
  64. }
  65. SQLiteHelper.Instance.OpenConnection();
  66. try
  67. {
  68. ICollection keys = _typeIndexDic.Keys;
  69. foreach (int key in keys)
  70. {
  71. var names = new string[] { "typeIndex" };
  72. var values = new string[] { "" + _typeIndexDic[key] };
  73. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgArray), names, values, "id", key.ToString());
  74. }
  75. }
  76. catch (Exception e)
  77. {
  78. ET.Log.Error(e.ToString());
  79. }
  80. finally
  81. {
  82. SQLiteHelper.Instance.CloseConnection();
  83. }
  84. }
  85. public static void WriteCJShop()
  86. {
  87. // Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  88. // SQLiteHelper.Instance.OpenConnection();
  89. // try
  90. // {
  91. // string typeIndex = "";
  92. // int itemId;
  93. // int id;
  94. // var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJArray");
  95. // while (reader.Read())
  96. // {
  97. // typeIndex = reader["_typeIndex"].ToString();
  98. // itemId = int.Parse(reader["_itemId"].ToString());
  99. // id = int.Parse(reader["_id"].ToString());
  100. // int count;
  101. // if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  102. // {
  103. // count = Array.IndexOf(_shopItemType, typeIndex);
  104. // }
  105. // else
  106. // {
  107. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  108. // string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  109. // if (Array.IndexOf(_shopItemType, itemType) >= 0)
  110. // {
  111. // count = Array.IndexOf(_shopItemType, itemType);
  112. // }
  113. // else
  114. // {
  115. // count = _shopItemType.Length - 1;
  116. // }
  117. // }
  118. // _typeIndexDic.Add(id, count.ToString());
  119. // }
  120. // }
  121. // catch (System.Exception e)
  122. // {
  123. // ET.Log.Error(e);
  124. // }
  125. // finally
  126. // {
  127. // SQLiteHelper.Instance.CloseConnection();
  128. // }
  129. // SQLiteHelper.Instance.OpenConnection();
  130. // try
  131. // {
  132. // ICollection keys = _typeIndexDic.Keys;
  133. // foreach (int key in keys)
  134. // {
  135. // var names = new string[] { "typeIndex" };
  136. // var values = new string[] { "" + _typeIndexDic[key] };
  137. // SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJArray), names, values, "id", key.ToString());
  138. // }
  139. // }
  140. // catch (Exception e)
  141. // {
  142. // ET.Log.Error(e.ToString());
  143. // }
  144. // finally
  145. // {
  146. // SQLiteHelper.Instance.CloseConnection();
  147. // }
  148. }
  149. public static void WriteCJAShop()
  150. {
  151. // Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  152. // SQLiteHelper.Instance.OpenConnection();
  153. // try
  154. // {
  155. // string typeIndex = "";
  156. // int itemId;
  157. // int id;
  158. // var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJAArray");
  159. // while (reader.Read())
  160. // {
  161. // typeIndex = reader["_typeIndex"].ToString();
  162. // itemId = int.Parse(reader["_itemId"].ToString());
  163. // id = int.Parse(reader["_id"].ToString());
  164. // int count;
  165. // if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  166. // {
  167. // count = Array.IndexOf(_shopItemType, typeIndex);
  168. // }
  169. // else
  170. // {
  171. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  172. // string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  173. // if (Array.IndexOf(_shopItemType, itemType) >= 0)
  174. // {
  175. // count = Array.IndexOf(_shopItemType, itemType);
  176. // }
  177. // else
  178. // {
  179. // count = _shopItemType.Length - 1;
  180. // }
  181. // }
  182. // _typeIndexDic.Add(id, count.ToString());
  183. // }
  184. // }
  185. // catch (System.Exception e)
  186. // {
  187. // ET.Log.Error(e);
  188. // }
  189. // finally
  190. // {
  191. // SQLiteHelper.Instance.CloseConnection();
  192. // }
  193. // SQLiteHelper.Instance.OpenConnection();
  194. // try
  195. // {
  196. // ICollection keys = _typeIndexDic.Keys;
  197. // foreach (int key in keys)
  198. // {
  199. // var names = new string[] { "typeIndex" };
  200. // var values = new string[] { "" + _typeIndexDic[key] };
  201. // SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJAArray), names, values, "id", key.ToString());
  202. // }
  203. // }
  204. // catch (Exception e)
  205. // {
  206. // ET.Log.Error(e.ToString());
  207. // }
  208. // finally
  209. // {
  210. // SQLiteHelper.Instance.CloseConnection();
  211. // }
  212. }
  213. public static void WriteGalleryShop()
  214. {
  215. // Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  216. // SQLiteHelper.Instance.OpenConnection();
  217. // try
  218. // {
  219. // string typeIndex = "";
  220. // int itemId;
  221. // int id;
  222. // var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgGalleryArray");
  223. // while (reader.Read())
  224. // {
  225. // typeIndex = reader["_typeIndex"].ToString();
  226. // itemId = int.Parse(reader["_itemId"].ToString());
  227. // id = int.Parse(reader["_id"].ToString());
  228. // int count = 2;
  229. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  230. // if (itemCfg.itemType == ConstItemType.DRESS_UP)
  231. // {
  232. // if (itemCfg.subType == ConstDressUpItemType.BEI_JING)
  233. // {
  234. // count = 0;//背景
  235. // }
  236. // else
  237. // {
  238. // count = 2;//道具
  239. // }
  240. // }
  241. // else if (itemCfg.itemType == ConstItemType.PHOTOGRAPH)
  242. // {
  243. // if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_NPC)
  244. // {
  245. // count = 1;//人物
  246. // }
  247. // else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_BOREDR)
  248. // {
  249. // count = 3;//npc
  250. // }
  251. // else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_EFFECT)
  252. // {
  253. // count = 4;//滤镜
  254. // }
  255. // }
  256. // _typeIndexDic.Add(id, count.ToString());
  257. // }
  258. // }
  259. // catch (System.Exception e)
  260. // {
  261. // ET.Log.Error(e);
  262. // }
  263. // finally
  264. // {
  265. // SQLiteHelper.Instance.CloseConnection();
  266. // }
  267. // SQLiteHelper.Instance.OpenConnection();
  268. // try
  269. // {
  270. // ICollection keys = _typeIndexDic.Keys;
  271. // foreach (int key in keys)
  272. // {
  273. // var names = new string[] { "typeIndex" };
  274. // var values = new string[] { "" + _typeIndexDic[key] };
  275. // SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgGalleryArray), names, values, "id", key.ToString());
  276. // }
  277. // }
  278. // catch (Exception e)
  279. // {
  280. // ET.Log.Error(e.ToString());
  281. // }
  282. // finally
  283. // {
  284. // SQLiteHelper.Instance.CloseConnection();
  285. // }
  286. }
  287. }
  288. }