ShopScanner.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. public static void StartScan()
  15. {
  16. WriteClothingShop();
  17. WriteCJShop();
  18. WriteCJAShop();
  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. }
  213. }