using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using GFGGame; using UnityEngine; namespace GFGEditor { public class ShopScanner { //计算每个副本的关卡数 private static Dictionary levelCountDIc = new Dictionary(); // private static string[] _shopItemType = new string[] { "推荐", "发型", "连衣裙", "内搭", "上衣", "下装", "外套", "袜子", "鞋子", "饰品" }; private static string[] _shopItemType = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; public static void StartScan() { WriteClothingShop(); WriteCJShop(); WriteCJAShop(); } public static void WriteClothingShop() { Dictionary _typeIndexDic = new Dictionary(); SQLiteHelper.Instance.OpenConnection(); try { string typeIndex = ""; int itemId; int id; var reader = SQLiteHelper.Instance.ReadLine("ShopCfgClothingArray"); while (reader.Read()) { typeIndex = reader["_typeIndex"].ToString(); itemId = int.Parse(reader["_itemId"].ToString()); id = int.Parse(reader["_id"].ToString()); int count; if (Array.IndexOf(_shopItemType, typeIndex) >= 0) { count = Array.IndexOf(_shopItemType, typeIndex); } else { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId); string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString(); if (Array.IndexOf(_shopItemType, itemType) >= 0) { count = Array.IndexOf(_shopItemType, itemType); } else { count = _shopItemType.Length - 1; } } _typeIndexDic.Add(id, count.ToString()); } } catch (System.Exception e) { ET.Log.Error(e); } finally { SQLiteHelper.Instance.CloseConnection(); } SQLiteHelper.Instance.OpenConnection(); try { ICollection keys = _typeIndexDic.Keys; foreach (int key in keys) { var names = new string[] { "typeIndex" }; var values = new string[] { "" + _typeIndexDic[key] }; SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgClothingArray), names, values, "id", key.ToString()); } } catch (Exception e) { ET.Log.Error(e.ToString()); } finally { SQLiteHelper.Instance.CloseConnection(); } } public static void WriteCJShop() { Dictionary _typeIndexDic = new Dictionary(); SQLiteHelper.Instance.OpenConnection(); try { string typeIndex = ""; int itemId; int id; var reader = SQLiteHelper.Instance.ReadLine("ShopCfgCJArray"); while (reader.Read()) { typeIndex = reader["_typeIndex"].ToString(); itemId = int.Parse(reader["_itemId"].ToString()); id = int.Parse(reader["_id"].ToString()); int count; if (Array.IndexOf(_shopItemType, typeIndex) >= 0) { count = Array.IndexOf(_shopItemType, typeIndex); } else { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId); string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString(); if (Array.IndexOf(_shopItemType, itemType) >= 0) { count = Array.IndexOf(_shopItemType, itemType); } else { count = _shopItemType.Length - 1; } } _typeIndexDic.Add(id, count.ToString()); } } catch (System.Exception e) { ET.Log.Error(e); } finally { SQLiteHelper.Instance.CloseConnection(); } SQLiteHelper.Instance.OpenConnection(); try { ICollection keys = _typeIndexDic.Keys; foreach (int key in keys) { var names = new string[] { "typeIndex" }; var values = new string[] { "" + _typeIndexDic[key] }; SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJArray), names, values, "id", key.ToString()); } } catch (Exception e) { ET.Log.Error(e.ToString()); } finally { SQLiteHelper.Instance.CloseConnection(); } } public static void WriteCJAShop() { Dictionary _typeIndexDic = new Dictionary(); SQLiteHelper.Instance.OpenConnection(); try { string typeIndex = ""; int itemId; int id; var reader = SQLiteHelper.Instance.ReadLine("ShopCfgCJAArray"); while (reader.Read()) { typeIndex = reader["_typeIndex"].ToString(); itemId = int.Parse(reader["_itemId"].ToString()); id = int.Parse(reader["_id"].ToString()); int count; if (Array.IndexOf(_shopItemType, typeIndex) >= 0) { count = Array.IndexOf(_shopItemType, typeIndex); } else { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId); string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString(); if (Array.IndexOf(_shopItemType, itemType) >= 0) { count = Array.IndexOf(_shopItemType, itemType); } else { count = _shopItemType.Length - 1; } } _typeIndexDic.Add(id, count.ToString()); } } catch (System.Exception e) { ET.Log.Error(e); } finally { SQLiteHelper.Instance.CloseConnection(); } SQLiteHelper.Instance.OpenConnection(); try { ICollection keys = _typeIndexDic.Keys; foreach (int key in keys) { var names = new string[] { "typeIndex" }; var values = new string[] { "" + _typeIndexDic[key] }; SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJAArray), names, values, "id", key.ToString()); } } catch (Exception e) { ET.Log.Error(e.ToString()); } finally { SQLiteHelper.Instance.CloseConnection(); } } } }