ShopScanner.cs 12 KB

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