public bool IsAffordable(DictionaryStringToInt cost) { foreach (KeyValuePair <string, int> resource in cost) { if (resource.Value > (ItemManager.Instance.AllResources.ContainsKey(resource.Key) ? ItemManager.Instance.AllResources[resource.Key].Amount : 0)) { //Debug.Log($"Not enough Resource ({LoadManager.Instance.allResourceData[resource.Key].Name})"); return(false); } } return(true); }
bool ConsumeBuildingCost(Builder builder) { Building buildingData = LoadManager.Instance.allBuildingData[builder.Type]; DictionaryStringToInt buidingCost = buildingData.buildingCost[builder.Level]; // List<Character> characters = BuildingManager.Instance.allBuildings.SingleOrDefault(b => b.Type == Building.BuildingType.LaborCenter).CharacterInBuilding; if (ItemManager.Instance.TryConsumeResources(buidingCost)) { return(true); } else { return(false); } }
public bool TryConsumeResources(DictionaryStringToInt resources) { if (IsAffordable(resources)) { foreach (KeyValuePair <string, int> resource in resources) { ConsumeResource(resource); } } else { return(false); } return(true); }
public CraftingData(DictionaryStringToInt craftingMaterials, int point) { this.craftingMaterials = craftingMaterials; this.pointRequired = point; }