Пример #1
0
 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);
        }
    }
Пример #3
0
    public bool TryConsumeResources(DictionaryStringToInt resources)
    {
        if (IsAffordable(resources))
        {
            foreach (KeyValuePair <string, int> resource in resources)
            {
                ConsumeResource(resource);
            }
        }
        else
        {
            return(false);
        }

        return(true);
    }
Пример #4
0
 public CraftingData(DictionaryStringToInt craftingMaterials, int point)
 {
     this.craftingMaterials = craftingMaterials;
     this.pointRequired     = point;
 }