Exemple #1
0
        public static bool TryPurchase(LandPlotUI kiosk, PlotUpgrade upgrade)
        {
#if !SR_VANILLA
            LandPlot           plot    = kiosk.Get_LandPlot();
            PlotUpgradeTracker tracker = plot.GetComponent <PlotUpgradeTracker>();

            if (tracker.HasUpgrade(upgrade))
            {
                kiosk.Error("e.already_has_upgrade");
            }
            else if (Player.Currency >= upgrade.Cost)
            {
                Sound.Play(SoundId.PURCHASED_PLOT_UPGRADE);
                Player.SpendCurrency(upgrade.Cost, false);
                tracker.Add(upgrade);
                kiosk.Close();
                return(true);
            }
            else
            {
                Sound.Play(SoundId.ERROR);
                kiosk.Error("e.insuf_coins");
            }
#endif
            return(false);
        }
 public bool CanBuy(PlotUpgradeTracker plot)
 {
     if (!PrereqsMet(plot))
     {
         return(false);
     }
     if (plot.HasUpgrade(this))
     {
         return(false);
     }
     if (can_buy_func != null)
     {
         return(can_buy_func());
     }
     return(true);
 }