Exemple #1
0
    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;
    }
Exemple #2
0
    public PlaceData(string _placeID)
    {
        skillCT = new TerritorySkillController(this);

        placeID       = _placeID;
        placeBaseData = GameDataManager.placeBaseDataDic[placeID];
        product       = GameDataManager.itemDic[placeBaseData.productID];

        heroList.onAdd        += OnAddHero;
        heroList.onRemovePost += OnRemoveHero;

        TerritoryManager.onAddPlace         += CalculatePlaceBuffValue;
        TerritoryManager.onChangedPlaceData += CalculatePlaceBuffValue;

        CalculatePlaceBuffValue();

        float formula = 0;

        float.TryParse(placeBaseData.formula, out formula);
        power = formula * placeLevel;

        if (ObscuredPrefs.HasKey(placeID + saveKey))
        {
            string _data = ObscuredPrefs.GetString(placeID + 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         = placeID;
                heroList.Add(heroData);
            }
        }
    }