public void Clear() { Inited = false; First = null; dic.Clear(); Items.Clear(); }
public void Init() { if (!Table.Inited) { throw new Exception("Tabele has not been initialised,it is intialised in GameController"); } if (!Inited) { TableGoods preItem = null; string tableStr = TableTool.GetTxt(FileName); JSONNode data = JSONNode.Parse(tableStr); foreach (var itemData in data.Children) { TableGoods item = new TableGoods(); item.Id = itemData["Id"]; item.Name = itemData["Name"]; item.Icon = itemData["Icon"]; item.GoodsType = itemData["GoodsType"]; item.Des = itemData["Des"]; AddItem(item); if (preItem != null) { preItem.Next = item; } preItem = item; } Inited = true; } }
private static void AddItem(TableGoods item) { if (First == null) { First = item; } if (dic.ContainsKey(item.Id)) { DebugUtil.LogError(FileName + " id duplicate :" + item.Id); } else { dic.Add(item.Id, item); Items.Add(item); } }
public void Init(string tableStr) { TableGoods preItem = null; JSONNode data = JSONNode.Parse(tableStr); foreach (var itemData in data.Children) { TableGoods item = new TableGoods(); item.Id = itemData["Id"]; item.Name = itemData["Name"]; item.Icon = itemData["Icon"]; item.GoodsType = itemData["GoodsType"]; item.Des = itemData["Des"]; AddItem(item); if (preItem != null) { preItem.Next = item; } preItem = item; } }