コード例 #1
0
    private static void Init(string _info)
    {
        List <object> jsonObjects = MiniJSON.Json.Deserialize(_info) as List <object>;

        for (int i = 0; i < jsonObjects.Count; i++)
        {
            D_ModelResource             info       = new D_ModelResource();
            Dictionary <string, object> jsonObject = jsonObjects[i] as Dictionary <string, object>;

            if (jsonObject["id"] != null)
            {
                info._id = int.Parse(jsonObject["id"].ToString());
            }
            if (jsonObject["modelName"] != null)
            {
                info._modelName = jsonObject["modelName"].ToString();
            }
            if (jsonObject["modelPath"] != null)
            {
                info._modelPath = jsonObject["modelPath"].ToString();
            }

            infoDict.Add(info._id, info);
        }

        /*
         * foreach (KeyValuePair<int, D_ModelResource> info in infoDict)
         * {
         *  Debug.Log(">>>>>"+info.Value._id+":"+info.Value._name+":"+info.Value._desc+":"+info.Value._point+":"+info.Value._label+":"+info.Value._type+":"+info.Value._number+":"+info.Value._function+":"+info.Value._para+":"+info.Value._reward+":"+"<<<<<\n");
         * }
         */
    }
コード例 #2
0
    /// <summary>
    /// 通过key获取数据
    /// </summary>
    /// <param name="_id">字典key</param>
    /// <returns></returns>
    public static D_ModelResource GetData(int _id)
    {
        D_ModelResource data = null;

        if (infoDict.ContainsKey(_id))
        {
            data = infoDict[_id];
        }
        else
        {
            Debug.Log(">>>>>table:" + tableName + " id:" + _id + " is null<<<<<\n");
        }
        return(data);
    }