private Dictionary <string, long> GetStoredComponents(ProductionConfig config) { var amountsPerMaterial = new Dictionary <string, long>(); foreach (var material in config.ProductionGoals.Keys) { var itemType = materialDict[material]; var amount = GetItemCount(itemType, config.Containers); amountsPerMaterial.Add(material, amount); } return(amountsPerMaterial); }
public void SetupView(ProductionConfig config) { _mapObjectId = config.MapObject; buildingNameText.text = config.Id; var resources = config.ProductionCostData; foreach (var resource in resources) { var costItem = GetCostItem(); costItem.SetView(AssetIconHelper.GetSpriteForResource(resource.Resource), resource.Amount); } }
public static void SetMapObjectWithIdAt(ProductionConfig config, string buildingId, Vector3 worldPosition) { var asset = GetMapObject(config.MapObjectAsset); var buildingDecoration = asset.GetComponent <BuildingBehaviour>(); if (buildingDecoration != null) { buildingDecoration.BuildingId = buildingId; var convertedPosition = new Vector3(worldPosition.x - worldPosition.x % 10, 0, worldPosition.z - worldPosition.z % 10); asset.transform.position = convertedPosition; } }
public static bool TryGetConfig(MapObject id, out ProductionConfig productionConfig) { productionConfig = null; var configContext = Contexts.sharedInstance.config; if (configContext.hasGameConfig) { var config = configContext.gameConfigEntity.gameConfig.value.Productions.Config; productionConfig = config.SingleOrDefault(x => x.MapObject == id); if (productionConfig != null) { return(true); } } return(false); }
private void CalculateProductionState(ProductionConfig config) { var storedComponents = GetStoredComponents(config); foreach (var productionGoals in config.ProductionGoals) { var amountOfThisComponentInStorage = storedComponents[productionGoals.Key]; var productionLevel = 0; foreach (var level in productionGoals.Value) { if (amountOfThisComponentInStorage >= level) { productionLevel += 1; } } if (config.CurrentlyProducedLevel > productionLevel) { config.CurrentlyProducedLevel = productionLevel; config.CurrentlyProducedItem = productionGoals.Key; } } }
public static GameEntity CreateProductionEntity(this GameContext gameContext, ProductionConfig config, string buildingId) { var productionEntity = gameContext.CreateConstructionEntity(config, buildingId); var production = new ProductionData { MapObject = config.MapObject, IsInProduction = false, IsAuto = config.Auto }; productionEntity.ReplaceProduction(production); return(productionEntity); }
public static GameEntity CreateConstructionEntity(this GameContext gameContext, ProductionConfig config, string buildingId) { var productionEntity = gameContext.CreateEntity(); productionEntity.isConstruction = true; productionEntity.ReplaceTimeLeft(config.ProductionDelay); productionEntity.ReplaceTotalTime(config.ProductionDelay); productionEntity.AddBuildingId(buildingId); return(productionEntity); }