using System; using System.Collections; using System.Collections.Generic; using GFGGame; namespace GFGEditor { public class ShopScanner { // private static string[] _shopItemType = new string[] { "推荐", "发型", "连衣裙", "内搭", "上衣", "下装", "外套", "袜子", "鞋子", "饰品" }; private static string[] _shopItemType = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; //[背景,人物,道具,边框,滤镜] private static string[] _galleryShopItemType = new string[] { "0", "1", "2", "3", "4" }; public static void StartScan() { WriteClothingShop(); WriteCJShop(); WriteCJAShop(); WriteGalleryShop(); } public static void WriteClothingShop() { Dictionary _typeIndexDic = new Dictionary(); SQLiteHelper.Instance.OpenConnection(); try { string typeIndex = ""; int itemId; int id; var reader = SQLiteHelper.Instance.ReadFullTable("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.ReadFullTable("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.ReadFullTable("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(); } } public static void WriteGalleryShop() { Dictionary _typeIndexDic = new Dictionary(); SQLiteHelper.Instance.OpenConnection(); try { string typeIndex = ""; int itemId; int id; var reader = SQLiteHelper.Instance.ReadFullTable("ShopCfgGalleryArray"); while (reader.Read()) { typeIndex = reader["_typeIndex"].ToString(); itemId = int.Parse(reader["_itemId"].ToString()); id = int.Parse(reader["_id"].ToString()); int count = 2; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId); if (itemCfg.itemType == ConstItemType.DRESS_UP) { if (itemCfg.subType == ConstDressUpItemType.BEI_JING) { count = 0;//背景 } else { count = 2;//道具 } } else if (itemCfg.itemType == ConstItemType.PHOTOGRAPH) { if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_NPC) { count = 1;//人物 } else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_BOREDR) { count = 3;//npc } else if (itemCfg.subType == ConstItemSubType.PHOTOGRAPH_EFFECT) { count = 4;//滤镜 } } _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(ShopCfgGalleryArray), names, values, "id", key.ToString()); } } catch (Exception e) { ET.Log.Error(e.ToString()); } finally { SQLiteHelper.Instance.CloseConnection(); } } } }