ShopScanner.cs 11 KB

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