Ejemplo n.º 1
0
        public static E2JLoader CreateLoaderByHash(uint hash)
        {
            E2JLoader loader = null;

            switch (hash)
            {
            case 1413216339:
            {
                loader = new E2JTableList();
            }
            break;

            case 1309828047:
            {
                loader = new E2JConfig();
            }
            break;
            }

            return(loader);
        }
Ejemplo n.º 2
0
        void ParseJson(string tableKey, E2JKeyType keyType)
        {
            uint hash = BKDRHash(tableKey);

            try
            {
                TextAsset jsonText = Resources.Load(_jsonPath + tableKey) as TextAsset;
                Hashtable jsonHt   = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(jsonText.text);

                switch (keyType)
                {
                case E2JKeyType.Int:
                {
                    _tableIntDict.Remove(tableKey);

                    Dictionary <int, E2JLoader> intDict = new Dictionary <int, E2JLoader>();

                    foreach (object jsonKey in jsonHt.Keys)
                    {
                        string    key   = jsonKey as string;
                        string    value = jsonHt[key].ToString();
                        Hashtable ht    = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(value);

                        E2JLoader loader = E2JHashHelper.CreateLoaderByHash(hash);
                        loader.Load(ht);

                        intDict.Add(int.Parse(key), loader);
                    }

                    _tableIntDict.Add(tableKey, intDict);
                }
                break;

                case E2JKeyType.String:
                {
                    _tableStringDict.Remove(tableKey);

                    Dictionary <string, E2JLoader> stringDict = new Dictionary <string, E2JLoader>();

                    foreach (object jsonKey in jsonHt.Keys)
                    {
                        string    key   = jsonKey as string;
                        string    value = jsonHt[key].ToString();
                        Hashtable ht    = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(value);

                        E2JLoader loader = E2JHashHelper.CreateLoaderByHash(hash);
                        loader.Load(ht);

                        stringDict.Add(key, loader);
                    }

                    _tableStringDict.Add(tableKey, stringDict);
                }
                break;
                }
            }
            catch (System.Exception ex)
            {
                Log.Error("E2JManager ParseJson exception: " + ex.ToString());
            }
        }