//============================================ //--4>: // Exported by ExcelConfigExport // // 此代码为工具根据配置自动生成, 请不要修改 // //============================================ using System; using Sog; using System.Collections.Generic; using Newtonsoft.Json.Linq; using System.IO; using System.Linq; public partial class ItemDescMgr : IConfigManager { //Singleton private static ItemDescMgr _instance; private static readonly object syslock = new object(); public static ItemDescMgr Instance { get { if (_instance == null) { lock (syslock) { if (_instance == null) { _instance = new ItemDescMgr(); }}} return _instance; }} public class ItemData { public ItemDesc Item; public int Line; public bool ReadAlready; } protected Dictionary m_ItemTable = new (); protected Dictionary n_ItemTable = new (); //for server only, m_readKeyOnly must be false protected SortedList m_ItemDescTable = new (); public SortedList ItemTable { get { if (m_ItemDescTable.Count == 0) { foreach (var item in m_ItemTable) { m_ItemDescTable.Add(item.Key, item.Value.Item); }} return m_ItemDescTable; } } private TabBinFile m_tbf; //private TabTextFile m_tf; private int m_curAsynKey1; public override bool InitBin(string fileName, byte[] fileContent) { m_ErrorCount = 0; m_ItemTable.Clear(); n_ItemTable.Clear(); m_ItemDescTable.Clear(); m_allRead = false; m_curAsynKey1 = 0; m_tbf = new TabBinFile(fileName, fileContent); while (m_tbf.Next()) { ItemData itemData = new ItemData() { Item = new ItemDesc() }; var item = itemData.Item; if (m_readKeyOnly) {m_tbf.SetCurrentCol(0); } if (item.ReadItemBin(m_tbf, m_readKeyOnly) == false) { TraceLog.Error("Failed to InitBin TabManager:{0}, read line error, line: {1}", this.ToString(), m_tbf.CurrentLine); m_ErrorCount++; continue; } if (m_ItemTable.ContainsKey(item.GetKey1())) { TraceLog.Error("Failed to InitBin TabManager:{0}, multi key:{1}, line: {2}", this.ToString(), item.GetKey1(), m_tbf.CurrentLine); m_ErrorCount++; continue; } m_ItemTable.Add(item.GetKey1(), itemData); n_ItemTable.Add(item.InternalId, item); if (m_readKeyOnly) { itemData.Line = m_tbf.CurrentLine; } else { itemData.ReadAlready = true; } } if (!m_readKeyOnly) { m_tbf = null; } return true; } public ItemDesc GetConfig(string key) { ItemData itemData; if (m_ItemTable.TryGetValue(key, out itemData) == false) { return null; } if(itemData.ReadAlready) { return itemData.Item; } if (m_tbf == null) { TraceLog.Error("Cfg1KeyMgrTemplate.GetConfig Failed fs null TabManager:{ 0}, read line error,", this.ToString()); return null; } m_tbf.SetCurrentLine(itemData.Line); m_tbf.SetCurrentCol(0); itemData.ReadAlready = true; if (itemData.Item.ReadItemBin(m_tbf, false) == false) { TraceLog.Error("Cfg1KeyMgrTemplate.GetConfig Failed to init TabManager:{0}, read line error, line: {1}", this.ToString(), m_tbf.CurrentLine); return null; } return itemData.Item; } public ItemDesc GetConfigByInternal(int internalId) { var desc = n_ItemTable.GetValueOrDefault(internalId, null); if (desc == null) { TraceLog.Error("Cfg1KeyMgrTemplate.Get by InternalId Failed fs null TabManager:{0}, internalId={1},read line error,", this.ToString(), internalId); } return desc; } } public partial class ItemDesc { public static readonly string _KEY_InternalId = "InternalId"; public static readonly string _KEY_itemID = "itemID"; public static readonly string _KEY_isShowBag = "isShowBag"; public static readonly string _KEY_type = "type"; public static readonly string _KEY_useType = "useType"; public static readonly string _KEY_quality = "quality"; public static readonly string _KEY_chooseItemType = "chooseItemType"; public static readonly string _KEY_chooseItemId = "chooseItemId"; public static readonly string _KEY_chooseItemNum = "chooseItemNum"; public static readonly string _KEY_mixItemType = "mixItemType"; public static readonly string _KEY_mixItemId = "mixItemId"; public static readonly string _KEY_mixItemNum = "mixItemNum"; public static readonly string _KEY_randomItemType = "randomItemType"; public static readonly string _KEY_randomItemId = "randomItemId"; public static readonly string _KEY_randomItemNum = "randomItemNum"; public static readonly string _KEY_useConditions = "useConditions"; public static readonly string _KEY_useConditionsNum = "useConditionsNum"; public static readonly string _KEY_packItemType = "packItemType"; public static readonly string _KEY_packItemId = "packItemId"; public static readonly string _KEY_packItemNum = "packItemNum"; public static readonly string _KEY_conversionItemId = "conversionItemId"; public static readonly string _KEY_conversionItemValue = "conversionItemValue"; /// /// 内部ID /// public int InternalId { get; set; } /// /// 物品的ID /// public string itemID { get; set; } /// /// 是否在背包显示,必须配置 /// public Bool isShowBag { get; set; } /// /// 道具类型 /// public ItemType type { get; set; } /// /// 使用类型 /// public string useType { get; set; } /// /// 品质 /// public CommonQuality quality { get; set; } /// /// 自选道具类型 /// public int[] chooseItemType { get; set; } /// /// 自选道具ID /// public string[] chooseItemId { get; set; } /// /// 自选道具数量 /// public int[] chooseItemNum { get; set; } /// /// 合成道具类型 /// public int mixItemType { get; set; } /// /// 合成道具ID /// public string mixItemId { get; set; } /// /// 合成道具数量 /// public int mixItemNum { get; set; } /// /// 随机道具类型(前端预览用) /// public int[] randomItemType { get; set; } /// /// 随机道具ID(前端预览用) /// public string[] randomItemId { get; set; } /// /// 随机道具数量(前端预览用) /// public int[] randomItemNum { get; set; } /// /// 使用条件,填多个为且关系 0、无条件 1、宝箱等级达到X级 2、玩家达到X级 /// public int[] useConditions { get; set; } /// /// 使用参数 /// public int[] useConditionsNum { get; set; } /// /// 礼包道具类型(可获得所有道具) /// public int[] packItemType { get; set; } /// /// 礼包道具ID(可获得所有道具) /// public string[] packItemId { get; set; } /// /// 礼包道具数量(可获得所有道具) /// public int[] packItemNum { get; set; } /// /// 活动结束转换道具id /// public string conversionItemId { get; set; } /// /// 转换道具数量 /// public int conversionItemValue { get; set; } public Dictionary listDic = new Dictionary(); public ItemDesc() { } public string GetKey1() { return itemID; } public bool ReadItemBin(TabBinFile txf, bool readKeyOnly) { InternalId = txf.GetintByIndex(_KEY_InternalId); itemID = txf.GetstringByIndex(_KEY_itemID); if(readKeyOnly) { return true; } isShowBag = (Bool)txf.GetintByIndex(_KEY_isShowBag); type = (ItemType)txf.GetintByIndex(_KEY_type); useType = txf.GetstringByIndex(_KEY_useType); quality = (CommonQuality)txf.GetintByIndex(_KEY_quality); chooseItemType = txf.GetintArrayByIndex(_KEY_chooseItemType); chooseItemId = txf.GetstringArrayByIndex(_KEY_chooseItemId); chooseItemNum = txf.GetintArrayByIndex(_KEY_chooseItemNum); mixItemType = txf.GetintByIndex(_KEY_mixItemType); mixItemId = txf.GetstringByIndex(_KEY_mixItemId); mixItemNum = txf.GetintByIndex(_KEY_mixItemNum); randomItemType = txf.GetintArrayByIndex(_KEY_randomItemType); randomItemId = txf.GetstringArrayByIndex(_KEY_randomItemId); randomItemNum = txf.GetintArrayByIndex(_KEY_randomItemNum); useConditions = txf.GetintArrayByIndex(_KEY_useConditions); useConditionsNum = txf.GetintArrayByIndex(_KEY_useConditionsNum); packItemType = txf.GetintArrayByIndex(_KEY_packItemType); packItemId = txf.GetstringArrayByIndex(_KEY_packItemId); packItemNum = txf.GetintArrayByIndex(_KEY_packItemNum); conversionItemId = txf.GetstringByIndex(_KEY_conversionItemId); conversionItemValue = txf.GetintByIndex(_KEY_conversionItemValue); return true; } }