ShopScanner.cs 11 KB

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