ShopScanner.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. //计算每个副本的关卡数
  13. private static Dictionary<int, int> levelCountDIc = new Dictionary<int, int>();
  14. // private static string[] _shopItemType = new string[] { "推荐", "发型", "连衣裙", "内搭", "上衣", "下装", "外套", "袜子", "鞋子", "饰品" };
  15. private static string[] _shopItemType = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  16. public static void StartScan()
  17. {
  18. WriteClothingShop();
  19. WriteCJShop();
  20. WriteCJAShop();
  21. }
  22. public static void WriteClothingShop()
  23. {
  24. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  25. SQLiteHelper.Instance.OpenConnection();
  26. try
  27. {
  28. string typeIndex = "";
  29. int itemId;
  30. int id;
  31. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgClothingArray");
  32. while (reader.Read())
  33. {
  34. typeIndex = reader["_typeIndex"].ToString();
  35. itemId = int.Parse(reader["_itemId"].ToString());
  36. id = int.Parse(reader["_id"].ToString());
  37. int count;
  38. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  39. {
  40. count = Array.IndexOf(_shopItemType, typeIndex);
  41. }
  42. else
  43. {
  44. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  45. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  46. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  47. {
  48. count = Array.IndexOf(_shopItemType, itemType);
  49. }
  50. else
  51. {
  52. count = _shopItemType.Length - 1;
  53. }
  54. }
  55. _typeIndexDic.Add(id, count.ToString());
  56. }
  57. }
  58. catch (System.Exception e)
  59. {
  60. ET.Log.Error(e);
  61. }
  62. finally
  63. {
  64. SQLiteHelper.Instance.CloseConnection();
  65. }
  66. SQLiteHelper.Instance.OpenConnection();
  67. try
  68. {
  69. ICollection keys = _typeIndexDic.Keys;
  70. foreach (int key in keys)
  71. {
  72. var names = new string[] { "typeIndex" };
  73. var values = new string[] { "" + _typeIndexDic[key] };
  74. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgClothingArray), names, values, "id", key.ToString());
  75. }
  76. }
  77. catch (Exception e)
  78. {
  79. ET.Log.Error(e.ToString());
  80. }
  81. finally
  82. {
  83. SQLiteHelper.Instance.CloseConnection();
  84. }
  85. }
  86. public static void WriteCJShop()
  87. {
  88. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  89. SQLiteHelper.Instance.OpenConnection();
  90. try
  91. {
  92. string typeIndex = "";
  93. int itemId;
  94. int id;
  95. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJArray");
  96. while (reader.Read())
  97. {
  98. typeIndex = reader["_typeIndex"].ToString();
  99. itemId = int.Parse(reader["_itemId"].ToString());
  100. id = int.Parse(reader["_id"].ToString());
  101. int count;
  102. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  103. {
  104. count = Array.IndexOf(_shopItemType, typeIndex);
  105. }
  106. else
  107. {
  108. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  109. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  110. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  111. {
  112. count = Array.IndexOf(_shopItemType, itemType);
  113. }
  114. else
  115. {
  116. count = _shopItemType.Length - 1;
  117. }
  118. }
  119. _typeIndexDic.Add(id, count.ToString());
  120. }
  121. }
  122. catch (System.Exception e)
  123. {
  124. ET.Log.Error(e);
  125. }
  126. finally
  127. {
  128. SQLiteHelper.Instance.CloseConnection();
  129. }
  130. SQLiteHelper.Instance.OpenConnection();
  131. try
  132. {
  133. ICollection keys = _typeIndexDic.Keys;
  134. foreach (int key in keys)
  135. {
  136. var names = new string[] { "typeIndex" };
  137. var values = new string[] { "" + _typeIndexDic[key] };
  138. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJArray), names, values, "id", key.ToString());
  139. }
  140. }
  141. catch (Exception e)
  142. {
  143. ET.Log.Error(e.ToString());
  144. }
  145. finally
  146. {
  147. SQLiteHelper.Instance.CloseConnection();
  148. }
  149. }
  150. public static void WriteCJAShop()
  151. {
  152. Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
  153. SQLiteHelper.Instance.OpenConnection();
  154. try
  155. {
  156. string typeIndex = "";
  157. int itemId;
  158. int id;
  159. var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgCJAArray");
  160. while (reader.Read())
  161. {
  162. typeIndex = reader["_typeIndex"].ToString();
  163. itemId = int.Parse(reader["_itemId"].ToString());
  164. id = int.Parse(reader["_id"].ToString());
  165. int count;
  166. if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
  167. {
  168. count = Array.IndexOf(_shopItemType, typeIndex);
  169. }
  170. else
  171. {
  172. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  173. string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
  174. if (Array.IndexOf(_shopItemType, itemType) >= 0)
  175. {
  176. count = Array.IndexOf(_shopItemType, itemType);
  177. }
  178. else
  179. {
  180. count = _shopItemType.Length - 1;
  181. }
  182. }
  183. _typeIndexDic.Add(id, count.ToString());
  184. }
  185. }
  186. catch (System.Exception e)
  187. {
  188. ET.Log.Error(e);
  189. }
  190. finally
  191. {
  192. SQLiteHelper.Instance.CloseConnection();
  193. }
  194. SQLiteHelper.Instance.OpenConnection();
  195. try
  196. {
  197. ICollection keys = _typeIndexDic.Keys;
  198. foreach (int key in keys)
  199. {
  200. var names = new string[] { "typeIndex" };
  201. var values = new string[] { "" + _typeIndexDic[key] };
  202. SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJAArray), names, values, "id", key.ToString());
  203. }
  204. }
  205. catch (Exception e)
  206. {
  207. ET.Log.Error(e.ToString());
  208. }
  209. finally
  210. {
  211. SQLiteHelper.Instance.CloseConnection();
  212. }
  213. }
  214. }
  215. }