// Parameter constructor public ResearchCost(int gold, int research, ElementCost elementCost = null) { if (elementCost != null) { Wood = elementCost.Wood; Stone = elementCost.Stone; Iron = elementCost.Iron; Food = elementCost.Food; } Gold = gold; Research = research; }
private bool CheckRessourcesAvailability(ElementCost elementcost) { Ressources ressources = Ressources.Instance; if (ressources.WoodQty >= elementcost.Wood && ressources.StoneQty >= elementcost.Stone && ressources.IronQty >= elementcost.Iron && ressources.FoodQty >= elementcost.Food) { ressources.WoodQty -= (elementcost.Wood > 0) ? elementcost.Wood : 0; ressources.StoneQty -= (elementcost.Stone > 0) ? elementcost.Stone : 0; ressources.IronQty -= (elementcost.Iron > 0) ? elementcost.Iron : 0; ressources.FoodQty -= (elementcost.Food > 0) ? elementcost.Food : 0; return true; } return false; }