Exemplo n.º 1
0
        public void ImportOldJSON(HashRequist _HashRequist, DehashRequist _DehashRequist)
        //F4
        {
            lvlData.objs      = new LvlObject[] {};
            lvlData.creatures = new CreatureU[] {};
            base.ImportOldJSON(_HashRequist, _DehashRequist);
            if (jsonText != "")
            {
//			_HashRequist(jsonText, delegate(Hashtable LvlOld1){
//				string file=(string)LvlOld1["file"];
//				jsonText=(string)LvlOld1["lvl"];
                _HashRequist(jsonText, delegate(Hashtable LvlOld){
                    Hashtable bots = (Hashtable)LvlOld["bots"];
                    int count      = 0;
                    //Заполним список AssetBundle
                    double _id     = (double)LvlOld["id"];
                    lvlData.id     = Convert.ToInt32(_id);
                    Hashtable objs = (Hashtable)LvlOld["objs"];
                    foreach (string key in objs.Keys)
                    {
                        if (PlayerPrefs.GetInt("debug") == 1)
                        {
                            Debug.Log("LvlCfg.ImportOldJSON key=" + key);
                        }
                        _DehashRequist((Hashtable)objs[key], delegate(string _str){
                            LvlObject lo = (LvlObject)JsonUtility.FromJson(_str, typeof(LvlObject));
                            System.Array.Resize(ref lvlData.objs, lvlData.objs.Length + 1);
                            lvlData.objs[lvlData.objs.Length - 1] = lo;
                        });
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        CreatureU cu = new CreatureU();
                        if (bots["" + i] != null)
                        {
                            UnityScript.Lang.Array ba = (UnityScript.Lang.Array)bots["" + i];
                            cu.count = Convert.ToInt32(ba[0]);
                            cu.level = Convert.ToInt32(ba[1]);
                        }
                        else
                        {
                            cu.count = 0;
                            cu.level = 0;
                        }
                        System.Array.Resize(ref lvlData.creatures, lvlData.creatures.Length + 1);
                        lvlData.creatures[lvlData.creatures.Length - 1] = cu;
                    }
                    _DehashRequist((Hashtable)LvlOld["property"], delegate(string _str){
                        LvlObject lo     = (LvlObject)JsonUtility.FromJson(_str, typeof(LvlObject));
                        lvlData.property = (LvlProperty)JsonUtility.FromJson(_str, typeof(LvlProperty));
                    });
                });
//			});
            }
//		lvlData.objs=obja;
//		lvlData.creatures=creatures;
            jsonText = "";
        }
Exemplo n.º 2
0
 public void ImportOldJSON(HashRequist _HashRequist, DehashRequist _DehashRequist)
 {
     OnlyLoadJson();
 }
Exemplo n.º 3
0
/*
 *      public AssetBundle GetAssetBundle(string _name)
 *      {
 *                      try{
 *                              return settings.AssetBundleIndex[_name].bundle;
 *                      }catch
 *                      {
 *                              Debug.LogError("SettingsCfg.GetAssetBundle not defined name "+_name);
 *                      }
 *                      return null;
 *      }
 */

        public void ImportOldJSON(HashRequist _HashRequist, DehashRequist _DehashRequist)
        {
            int       i = 0;
            Hashtable obj;

            AssetBundleU[] abs       = new AssetBundleU[] {};
            TerrainU[]     terrains  = new TerrainU[] {};
            TowerU[]       towers    = new TowerU[] {};
            BotU[]         bots      = new BotU[] {};
            ResourceU[]    resources = new ResourceU[] {};
            WallU[]        walls     = new WallU[] {};
            ThingU[]       things    = new ThingU[] {};
            BulletU[]      bullets   = new BulletU[] {};
            BaseU[]        menus     = new BaseU[] {};

            BaseU bs;

            base.ImportOldJSON(_HashRequist, _DehashRequist);
            if (jsonText != "")
            {
                _HashRequist(jsonText, delegate(Hashtable SettingsOld){
                    int count = 0;
                    //Заполним список AssetBundle
                    obj          = (Hashtable)SettingsOld["AssetBundle"];
                    Hashtable ab = (Hashtable)obj["" + count];
                    while (ab != null)
                    {
                        AssetBundleU au = new AssetBundleU();
                        au.name         = (string)ab["name"];
//					au.downloaded=false;
                        System.Array.Resize(ref abs, abs.Length + 1);
                        abs[abs.Length - 1] = au;
                        count++;
                        ab = (Hashtable)obj["" + count];
                    }
                    //Заполним настройки
                    string[] prefixs = new string[] { "4-", "0-", "5-", "1-", "2-", "3-", "6-", "10-" };
                    for (i = 0; i < prefixs.Length; i++)
                    {
                        count         = 0;
                        string prefix = prefixs[i];
                        try{
                            obj = (Hashtable)SettingsOld[prefix + count];
                            while (obj != null)
                            {
                                switch (i)
                                {
                                case 0:
                                    //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings terrains="+obj);
                                    _DehashRequist(obj, delegate(string _str){
                                        TerrainU tn = (TerrainU)JsonUtility.FromJson(_str, typeof(TerrainU));
                                        System.Array.Resize(ref terrains, terrains.Length + 1);
                                        terrains[terrains.Length - 1] = tn;
                                    });
                                    break;

                                case 1:
                                    //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings towers="+obj);
                                    _DehashRequist(obj, delegate(string _str){
                                        TowerU tr = (TowerU)JsonUtility.FromJson(_str, typeof(TowerU));
                                        System.Array.Resize(ref towers, towers.Length + 1);
                                        towers[towers.Length - 1] = tr;
                                    });
                                    break;

                                case 2:
                                    //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj);
                                    _DehashRequist(obj, delegate(string _str){
                                        BotU bt = (BotU)JsonUtility.FromJson(_str, typeof(BotU));
                                        System.Array.Resize(ref bots, bots.Length + 1);
                                        bots[bots.Length - 1] = bt;
                                    });
                                    break;

                                case 3:
                                    //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj);
                                    _DehashRequist(obj, delegate(string _str){
                                        ResourceU re = (ResourceU)JsonUtility.FromJson(_str, typeof(ResourceU));
                                        System.Array.Resize(ref resources, resources.Length + 1);
                                        resources[resources.Length - 1] = re;
                                    });
                                    break;

                                case 4:
                                    //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj);
                                    _DehashRequist(obj, delegate(string _str){
                                        WallU wl = (WallU)JsonUtility.FromJson(_str, typeof(WallU));
                                        System.Array.Resize(ref walls, walls.Length + 1);
                                        walls[walls.Length - 1] = wl;
                                    });
                                    break;

                                case 5:
                                    _DehashRequist(obj, delegate(string _str){
                                        //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj);
                                        ThingU tg = (ThingU)JsonUtility.FromJson(_str, typeof(ThingU));
                                        System.Array.Resize(ref things, things.Length + 1);
                                        things[things.Length - 1] = tg;
                                    });
                                    break;

                                case 6:
                                    _DehashRequist(obj, delegate(string _str){
                                        //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj);
                                        BulletU bu = (BulletU)JsonUtility.FromJson(_str, typeof(BulletU));
                                        System.Array.Resize(ref bullets, bullets.Length + 1);
                                        bullets[bullets.Length - 1] = bu;
                                    });
                                    break;

                                case 7:
                                    _DehashRequist(obj, delegate(string _str){
                                        bs = (BaseU)JsonUtility.FromJson(_str, typeof(BaseU));
                                        System.Array.Resize(ref menus, menus.Length + 1);
                                        menus[menus.Length - 1] = bs;
                                    });
                                    break;
                                }
                                count++;
                                obj = (Hashtable)SettingsOld[prefix + count];
                            }
                        }catch
                        {
                        }
                    }
                });
            }
            jsonText = "";
            settings.AssetBundles = abs;

            settings.terrains  = terrains;
            settings.towers    = towers;
            settings.bots      = bots;
            settings.resources = resources;
            settings.walls     = walls;
            settings.things    = things;
            settings.bullets   = bullets;
            settings.menus     = menus;

            for (i = 0; i < settings.towers.Length; i++)
            {
                settings.towers[i].bulletInd = BulletIndex(settings.towers[i].bullet);
                settings.towers[i].bullet    = "";
            }
            for (i = 0; i < settings.bots.Length; i++)
            {
                settings.bots[i].bulletInd = BulletIndex(settings.bots[i].bullet);
                settings.bots[i].bullet    = "";
            }
        }