IEnumerator InitProductionLineBaseData() { JsonData json = null; yield return(StartCoroutine(AssetLoader.LoadJsonData("json", "ProductionLineBaseData", x => json = x))); productionLineBaseDataDic = new Dictionary <string, ProductionLineBaseData>(); for (int i = 0; i < json.Count; i++) { ProductionLineBaseData data = new ProductionLineBaseData(json[i]); productionLineBaseDataDic.Add(data.id, data); } }
public ProductionData(ProductionLineBaseData data) { skillCT = new TerritorySkillController(this); baseData = data; productionLineID = baseData.id; heroList.onAdd += OnAddHero; heroList.onRemovePost += OnRemoveHero; ProductManager.onChangedDeployHeroList += OnChangedDeployHeroList; ProductManager.onProductManagerInitialized += OnProductManagerInitialized; if (ObscuredPrefs.HasKey(productionLineID + saveKey)) { string _data = ObscuredPrefs.GetString(productionLineID + saveKey); if (string.IsNullOrEmpty(_data)) { return; } List <string> deployHeroIDList = JsonMapper.ToObject <List <string> >(new JsonReader(_data)); for (int i = 0; i < deployHeroIDList.Count; i++) { HeroData heroData = HeroManager.heroDataDic[deployHeroIDList[i]]; heroData.onChangedValue += OnChangedHeroData; heroData.placeID = productionLineID; heroList.Add(heroData); } } saveKeyApllyProduct = productionLineID + saveKeyApllyProduct + User.Instance.userID; if (ObscuredPrefs.HasKey(saveKeyApllyProduct)) { string productID = ObscuredPrefs.GetString(saveKeyApllyProduct); product = ProductManager.Instance.productList.Find(x => x.id == productID); } Storage.storedItemDic.onAdd += OnAddItemData; isInitialized = true; }