hashtableFromJson() public static méthode

public static hashtableFromJson ( this json ) : Hashtable
json this
Résultat Hashtable
        private static void InitDict(string path)
        {
            _rootBehavior = null;
            _behaviorDict.Clear();
            _connectionDict.Clear();
            TextAsset json           = Resources.Load <TextAsset>(path);
            string    content        = json.text.Replace("\r", "").Replace("\n", "");
            Hashtable table          = MiniJsonExtensions.hashtableFromJson(content);
            ArrayList nodeList       = table["nodes"] as ArrayList;
            ArrayList connectionList = table["connections"] as ArrayList;

            for (int i = 0; i < nodeList.Count; i++)
            {
                Hashtable nodeTable = nodeList[i] as Hashtable;
                var       id        = 0;
                if (int.TryParse(nodeTable["$id"].ToString(), out id))
                {
                    AbsBehavior absBehavior = CreateBehavior(nodeTable, id);
                    _behaviorDict[id] = absBehavior;
                    if (_rootBehavior == null)
                    {
                        _rootBehavior = absBehavior;
                    }
                    else
                    {
                        if (absBehavior.Id < _rootBehavior.Id)
                        {
                            _rootBehavior = absBehavior;
                        }
                    }
                }
                else
                {
                    LogHelper.PrintError("[BehaviorTreeFactory]try get node id error!");
                }
            }
            for (int i = 0; i < connectionList.Count; i++)
            {
                Hashtable connectionTable = connectionList[i] as Hashtable;
                int       source          = 0;
                int       target          = 0;
                Hashtable scurceNode      = connectionTable["_sourceNode"] as Hashtable;
                Hashtable targetNode      = connectionTable["_targetNode"] as Hashtable;
                if (int.TryParse(scurceNode["$ref"].ToString(), out source) &&
                    int.TryParse(targetNode["$ref"].ToString(), out target))
                {
                    List <int> list;
                    if (!_connectionDict.TryGetValue(source, out list))
                    {
                        _connectionDict[source] = new List <int>();
                        list = _connectionDict[source];
                    }
                    list.Add(target);
                }
                else
                {
                    LogHelper.PrintError("[BehaviorTreeFactory]try get source id and target id error!");
                }
            }
        }
Exemple #2
0
 private static void ReadConfig(string path)
 {
     _behaviorDict.Clear();
     _connectionDict.Clear();
     TextAsset json    = Resources.Load <TextAsset>(path);
     string    content = json.text.Replace("\r", "").Replace("\n", "");
     Hashtable table   = MiniJsonExtensions.hashtableFromJson(content);
     object    nodes   = table["nodes"];
 }
    public GameInfo(string rawJSON)
    {
        Hashtable gameInfo = MiniJsonExtensions.hashtableFromJson(rawJSON);

        Debug.Log("gameInfo Hashtable contains key games: " + gameInfo.ContainsKey("games"));

        ArrayList games = gameInfo["games"] as ArrayList;

        Debug.Log("Length of game array: " + games.Count);

        foreach (Hashtable hash in games)
        {
            Game game = new Game(hash);
            currentGames[game.name] = game;
        }
    }
Exemple #4
0
        /// <summary>
        /// 获取产品详细信息
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        private Hashtable getProductDetail(string productId)
        {
            string text = httpPost("https://msdn.itellyou.cn/Category/GetProduct", string.Format("id={0}", productId));

            return(MiniJsonExtensions.hashtableFromJson(text));
        }
Exemple #5
0
        /// <summary>
        /// 获取产品列表
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        private Hashtable getProductList(string typeId, string lang)
        {
            string text = httpPost("https://msdn.itellyou.cn/Category/GetList", string.Format("id={0}&lang={1}&filter=true", typeId, lang));

            return(MiniJsonExtensions.hashtableFromJson(text));
        }
Exemple #6
0
        /// <summary>
        /// 获取产品系列的语言列表
        /// </summary>
        /// <param name="typeId">资源类型id</param>
        /// <returns>多国语言、英语、中文 - 简体、中文 - 繁体...</returns>
        private Hashtable getLangList(string typeId)
        {
            string text = httpPost("https://msdn.itellyou.cn/Category/GetLang", string.Format("id={0}", typeId));

            return(MiniJsonExtensions.hashtableFromJson(text));
        }