Esempio n. 1
0
 public virtual void InitData()
 {
     if (items.Count == 0 || items == null)
     {
         TextAsset textAsset = ResourceManager.Instance.LoadRes <TextAsset> (ResourceManager.ResourceType.Data, mPath);
         if (textAsset != null)
         {
             string dataStr = textAsset.text;
             Dictionary <string, Dictionary <string, string> > datas = CSVTool.Parse(dataStr);
             foreach (string id in datas.Keys)
             {
                 TableItem item    = new TableItem();
                 int       idValue = int.Parse(id);
                 item.id      = idValue;
                 item.name    = datas[id]["name"];
                 item.account = int.Parse(datas[id]["account"]);
                 item.price   = float.Parse(datas[id]["price"]);
                 item.data    = datas[id]["data"];
                 items.Add(item);
                 this.d("damon", item.ToString(), false);
             }
         }
         else
         {
             Debug.Log(mPath);
         }
     }
 }
Esempio n. 2
0
        private void InitData()
        {
            TextAsset textAsset = ResourceManager.Instance.LoadRes <TextAsset> (ResourceManager.ResourceType.Data, "table");
            Dictionary <string, Dictionary <string, string> > dic = CSVTool.Parse(textAsset.text);

            foreach (string id in dic.Keys)
            {
                string    name      = dic[id]["name"];
                string    path      = dic[id]["resPath"];
                BaseTable baseTable = new BaseTable(name, path);
                mDic[mIndex++] = baseTable;
            }
        }
Esempio n. 3
0
    public override void OnSingletonInit()
    {
        base.OnSingletonInit();
        TextAsset text = ResourceManager.Instance.LoadRes <TextAsset> (ResourceManager.ResourceType.Data, "npc");

        if (text == null)
        {
            Debug.LogError("load npc data failed");
            return;
        }
        mDic = CSVTool.Parse(text.text);
        foreach (string id in mDic.Keys)
        {
            BaseNPC npc = new BaseNPC();
            npc.id       = int.Parse(id);
            npc.name     = mDic[id]["Name"];
            npc.position = mDic[id]["Position"];
            npc.task     = mDic[id]["Task"];
            npc.message  = mDic[id]["Message"];
            npc.resPath  = mDic[id]["ResPath"];
            npcs.Add(npc);
        }
    }
Esempio n. 4
0
    Dictionary <string, Dictionary <string, string> > GetTableData()
    {
        TextAsset text = ResourceManager.Instance.LoadRes <TextAsset> (ResourceManager.ResourceType.Data, "npc");

        return(CSVTool.Parse(text.text));
    }