public void SetTooltipData(ProductionData data) { _title.text = data.Name; _desc.text = data.Description; ResourceCost cost = data.Cost; _costs.text = string.Format(": {0}\n: {1}\n: {2}", cost.Gold, cost.Timber, cost.Food); }
private bool CanBuy(ResourceCost cost) { if (cost.Gold > _playerResourceData.Gold) { return(false); } if (cost.Timber > _playerResourceData.Timber) { return(false); } if ((cost.Food + _playerResourceData.Food) >= _playerResourceData.MaxFood) { return(false); } return(true); }
private void BuyAndAddToQueue(ProductionData item) { ResourceCost cost = item.Cost; if (!item.RequirementsMet()) { return; } bool canBuild = (_building.Queue.Count < 5) && CanBuy(cost); if (!canBuild) { return; } var dataToAdd = item as IQueueable; _building.AddToQueue(dataToAdd); _playerResourceData.AmendGold(-cost.Gold); _playerResourceData.AmendFood(cost.Food); _playerResourceData.AmendTimber(-cost.Timber); }
private void RefundCost(ResourceCost cost) { _playerResourceData.AmendGold(cost.Gold); _playerResourceData.AmendTimber(cost.Timber); _playerResourceData.AmendFood(-cost.Food); }