Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 private void RefundCost(ResourceCost cost)
 {
     _playerResourceData.AmendGold(cost.Gold);
     _playerResourceData.AmendTimber(cost.Timber);
     _playerResourceData.AmendFood(-cost.Food);
 }