You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
304 lines
8.6 KiB
304 lines
8.6 KiB
|
|
//============================================
|
|
//--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<string, ItemData> m_ItemTable = new ();
|
|
protected Dictionary<int, ItemDesc> n_ItemTable = new ();
|
|
//for server only, m_readKeyOnly must be false
|
|
protected SortedList<string, ItemDesc> m_ItemDescTable = new ();
|
|
public SortedList<string, ItemDesc> 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";
|
|
|
|
|
|
/// <summary>
|
|
/// 内部ID
|
|
/// </summary>
|
|
public int InternalId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 物品的ID
|
|
/// </summary>
|
|
public string itemID { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否在背包显示,必须配置
|
|
/// </summary>
|
|
public Bool isShowBag { get; set; }
|
|
|
|
/// <summary>
|
|
/// 道具类型
|
|
/// </summary>
|
|
public ItemType type { get; set; }
|
|
|
|
/// <summary>
|
|
/// 使用类型
|
|
/// </summary>
|
|
public string useType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 品质
|
|
/// </summary>
|
|
public CommonQuality quality { get; set; }
|
|
|
|
/// <summary>
|
|
/// 自选道具类型
|
|
/// </summary>
|
|
public int[] chooseItemType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 自选道具ID
|
|
/// </summary>
|
|
public string[] chooseItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 自选道具数量
|
|
/// </summary>
|
|
public int[] chooseItemNum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 合成道具类型
|
|
/// </summary>
|
|
public int mixItemType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 合成道具ID
|
|
/// </summary>
|
|
public string mixItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 合成道具数量
|
|
/// </summary>
|
|
public int mixItemNum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 随机道具类型(前端预览用)
|
|
/// </summary>
|
|
public int[] randomItemType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 随机道具ID(前端预览用)
|
|
/// </summary>
|
|
public string[] randomItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 随机道具数量(前端预览用)
|
|
/// </summary>
|
|
public int[] randomItemNum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 使用条件,填多个为且关系 0、无条件 1、宝箱等级达到X级 2、玩家达到X级
|
|
/// </summary>
|
|
public int[] useConditions { get; set; }
|
|
|
|
/// <summary>
|
|
/// 使用参数
|
|
/// </summary>
|
|
public int[] useConditionsNum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 礼包道具类型(可获得所有道具)
|
|
/// </summary>
|
|
public int[] packItemType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 礼包道具ID(可获得所有道具)
|
|
/// </summary>
|
|
public string[] packItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 礼包道具数量(可获得所有道具)
|
|
/// </summary>
|
|
public int[] packItemNum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 活动结束转换道具id
|
|
/// </summary>
|
|
public string conversionItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 转换道具数量
|
|
/// </summary>
|
|
public int conversionItemValue { get; set; }
|
|
|
|
public Dictionary<string, Type> listDic = new Dictionary<string, Type>();
|
|
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;
|
|
}
|
|
}
|
|
|
|
|