Example #1
0
 //Check if a building can be built
 public bool ableToBuild(abstractBuilding ab)
 {
     //Check each resource type required
     foreach (KeyValuePair<ResourceType, float> res in ab.ResourceToBuild) {
         //if the global count for the resource is lower than the required amount
         if (res.Value > getCurrentResource(res.Key)){
             //the building cannot be built
             return false;
         }
     }
     //if all resources are available, building can be built
     return true;
 }
Example #2
0
 //Check if a building can be built
 public bool ableToBuild(abstractBuilding ab)
 {
     //Check each resource type required
     foreach (KeyValuePair <ResourceType, float> res in ab.ResourceToBuild)
     {
         //if the global count for the resource is lower than the required amount
         if (res.Value > getCurrentResource(res.Key))
         {
             //the building cannot be built
             return(false);
         }
     }
     //if all resources are available, building can be built
     return(true);
 }