public void ReloadNewProduct(List <MercenaryType> newTypes) { List <MercenaryType> deleteType = new List <MercenaryType>(); foreach (MercenaryType type in this.m_Products.Keys) { if (!newTypes.Contains(type)) { deleteType.Add(type); } } foreach (MercenaryType type in newTypes) { if (!this.m_Products.ContainsKey(type)) { MercenaryConfigData configData = ConfigInterface.Instance.MercenaryConfigHelper.GetMercenaryData(type); MercenaryProductData productData = new MercenaryProductData(); productData.ConfigData = configData; productData.ReadyNumber = configData.MaxProduceNumber; this.m_Products.Add(type, new MercenaryProductLogicObject(type, productData)); } } foreach (MercenaryType type in deleteType) { this.m_Products.Remove(type); } }
public BuildingIdentity ConstructBuilding(BuildingType type, int builderBuildingNO, TilePosition position) { BuildingData data = new BuildingData(); BuildingConfigData configData = ConfigInterface.Instance.BuildingConfigHelper.GetBuildingData(type, 0); //int builderHutLevel = this.m_Buildings[BuildingType.BuilderHut][builderBuildingNO].Level; //BuilderConfigData builderData = ConfigInterface.Instance.BuilderConfigHelper.GetBuilderData(builderHutLevel); data.ConfigData = configData; int NO = this.m_Buildings.ContainsKey(type) ? this.m_Buildings[type].Count : 0; data.BuildingID = new BuildingIdentity(type, NO); data.Level = 0; data.UpgradeRemainingWorkload = configData.UpgradeWorkload; data.BuilderBuildingNO = builderBuildingNO; data.BuildingPosition = position; if (type == BuildingType.Tavern) { List <MercenaryType> mercenaryTypes = ConfigInterface.Instance.MercenaryConfigHelper.GetAvailableMercenaries(configData.InitialLevel); Dictionary <MercenaryType, MercenaryProductData> dict = new Dictionary <MercenaryType, MercenaryProductData>(); foreach (MercenaryType mercenaryType in mercenaryTypes) { MercenaryProductData productData = new MercenaryProductData(); MercenaryConfigData config = ConfigInterface.Instance.MercenaryConfigHelper.GetMercenaryData(mercenaryType); productData.ConfigData = config; productData.ReadyNumber = config.MaxProduceNumber; dict.Add(mercenaryType, productData); } data.ProduceMercenary = new MercenaryProductCollectionLogicObject(dict); } if (!this.m_Buildings.ContainsKey(type)) { this.m_Buildings.Add(type, new Dictionary <int, BuildingLogicObject>()); } this.m_Buildings[type].Add(data.BuildingID.buildingNO, this.ConstructBuildingLogicObject(data)); this.m_BuilderManager.SendBuilder(builderBuildingNO, this.GetBuildingObject(data.BuildingID)); this.m_CommunicationHelper.SendConstructBuildingRequest(data.BuildingID, position, builderBuildingNO); BuildingIdentity result = new BuildingIdentity(); result.buildingType = type; result.buildingNO = data.BuildingID.buildingNO; return(result); }
private BuildingData GenerateBuildingData(BuildingParameter param, List <ArmyData> armies, List <ItemData> items, Dictionary <MercenaryIdentity, MercenaryData> mercenaries, List <ObjectUpgrade <ArmyType> > armyUpgrades, List <ObjectUpgrade <ItemType> > itemUpgrades, UserData userData) { BuildingData result = new BuildingData(); BuildingConfigData configData = ConfigInterface.Instance.BuildingConfigHelper.GetBuildingData (param.BuildingTypeID, param.Level); result.ConfigData = configData; BuildingIdentity id = new BuildingIdentity(); id.buildingNO = param.BuildingNO; id.buildingType = param.BuildingTypeID; result.BuildingID = id; result.BuildingPosition = new TilePosition(param.PositionColumn, param.PositionRow); result.Level = param.Level; result.UpgradeRemainingWorkload = param.RemainWorkload; if (param.LastCollectGoldTick.HasValue) { result.LastCollectedGoldTick = param.LastCollectGoldTick.Value; } if (param.CollectedGold.HasValue) { result.CollectedGold = param.CollectedGold.Value; } if (param.LastCollectFoodTick.HasValue) { result.LastCollectedFoodTick = param.LastCollectFoodTick.Value; } if (param.CollectedFood.HasValue) { result.CollectedFood = param.CollectedFood.Value; } if (param.LastCollectOilTick.HasValue) { result.LastCollectedOilTick = param.LastCollectOilTick.Value; } if (param.CollectedOil.HasValue) { result.CollectedOil = param.CollectedOil.Value; } if (param.ArmyProducts != null) { result.ProduceArmy = new List <KeyValuePair <ArmyType, List <ArmyIdentity> > >(); ArmyType?previousType = null; foreach (ArmyProductParameter product in param.ArmyProducts) { if (previousType.HasValue && previousType.Value == product.ArmyType) { result.ProduceArmy[result.ProduceArmy.Count - 1].Value.Add(new ArmyIdentity(product.ArmyType, product.ArmyNO)); } else { List <ArmyIdentity> newList = new List <ArmyIdentity>() { new ArmyIdentity(product.ArmyType, product.ArmyNO) }; result.ProduceArmy.Add(new KeyValuePair <ArmyType, List <ArmyIdentity> >(product.ArmyType, newList)); } previousType = product.ArmyType; armies.Add(this.GenerateArmyData(product, userData)); } } if (param.Armies != null) { result.AvailableArmy = new List <ArmyIdentity>(); foreach (ArmyParameter army in param.Armies) { result.AvailableArmy.Add(new ArmyIdentity(army.ArmyType, army.ArmyNO)); armies.Add(this.GenerateArmyData(army, userData, id)); } } if (param.ArmyUpgrade != null) { result.ArmyUpgrade = param.ArmyUpgrade.ArmyType; ObjectUpgrade <ArmyType> upgrade = new ObjectUpgrade <ArmyType>(param.ArmyUpgrade.ArmyType, param.ArmyUpgrade.RemainingWorkload); armyUpgrades.Add(upgrade); } if (param.ItemProducts != null) { result.ProduceItem = new List <KeyValuePair <ItemType, List <ItemIdentity> > >(); ItemType?previousType = null; foreach (ItemProductParameter product in param.ItemProducts) { if (previousType.HasValue && previousType.Value == product.ItemType) { result.ProduceItem[result.ProduceItem.Count - 1].Value.Add(new ItemIdentity(product.ItemType, product.ItemNO)); } else { List <ItemIdentity> newList = new List <ItemIdentity>() { new ItemIdentity(product.ItemType, product.ItemNO) }; result.ProduceItem.Add(new KeyValuePair <ItemType, List <ItemIdentity> >(product.ItemType, newList)); } previousType = product.ItemType; items.Add(this.GenerateItemData(product, userData)); } } if (param.Items != null) { result.AvailableItem = new List <ItemIdentity>(); foreach (ItemParameter item in param.Items) { result.AvailableItem.Add(new ItemIdentity(item.ItemType, item.ItemNO)); items.Add(this.GenerateItemData(item, userData)); } } if (param.ItemUpgrade != null) { result.ItemUpgrade = param.ItemUpgrade.ItemType; ObjectUpgrade <ItemType> upgrade = new ObjectUpgrade <ItemType>(param.ItemUpgrade.ItemType, param.ItemUpgrade.RemainingWorkload); itemUpgrades.Add(upgrade); } if (param.Mercenaries != null) { result.AvailableMercenary = new List <MercenaryIdentity>(); foreach (MercenaryParameter mercenary in param.Mercenaries) { result.AvailableMercenary.Add(new MercenaryIdentity(mercenary.MercenaryType, mercenary.MercenaryNO)); mercenaries.Add(new MercenaryIdentity(mercenary.MercenaryType, mercenary.MercenaryNO), this.GenerateMercenaryData(mercenary, id)); } } if (param.MercenaryProducts != null) { Dictionary <MercenaryType, MercenaryProductData> dict = new Dictionary <MercenaryType, MercenaryProductData>(); foreach (MercenaryProductParameter mercenaryProduct in param.MercenaryProducts) { MercenaryProductData data = new MercenaryProductData(); data.ReadyNumber = mercenaryProduct.Number; data.RemainingTime = mercenaryProduct.RemainingSecond; data.ConfigData = ConfigInterface.Instance.MercenaryConfigHelper.GetMercenaryData(mercenaryProduct.MercenaryType); dict.Add(mercenaryProduct.MercenaryType, data); } result.ProduceMercenary = new MercenaryProductCollectionLogicObject(dict); } if (param.ResourceAccelerate != null) { result.RemainResourceAccelerateTime = param.ResourceAccelerate.RemainingTime; } if (param.ArmyAccelerate != null) { result.RemainArmyAccelerateTime = param.ArmyAccelerate.RemainingTime; } if (param.ItemAccelerate != null) { result.RemainItemAccelerateTime = param.ItemAccelerate.RemainingTime; } return(result); }
public MercenaryProductLogicData(MercenaryProductData data) { this.m_Data = data; }
public MercenaryProductLogicObject(MercenaryType type, MercenaryProductData data) { this.m_Type = type; this.m_Data = data; this.m_LogicData = new MercenaryProductLogicData(data); }