예제 #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);
        }
예제 #2
0
        public void Remove_Upgrade(PlotUpgrade upgrade)
        {
            bool b = upgrades.Remove(upgrade);

            if (!b)
            {
                SLog.Warn("Failed to remove custom plot upgrade from tracker. Upgrade: {0}", upgrade);
            }
        }
예제 #3
0
        internal void Load(LandPlot pl, Plot_Upgrades up)
        {
            this.plot = pl;
            this.ID   = new PlotID(plot);
            foreach (string upgradeName in up.upgrades)
            {
                PlotUpgrade upgrade = (PlotUpgrade)Upgrades.Get_Upgrade(Upgrade_Type.PLOT_UPGRADE, upgradeName);

                if (upgrade != null)
                {
                    this.upgrades.Add(upgrade);
                }
                else
                {
                    upgrades_missing.Add(upgradeName);
                }
            }
        }
예제 #4
0
 public bool HasUpgrade(PlotUpgrade upgrade)
 {
     return(allUpgrades.Contains(upgrade.ID));
 }
예제 #5
0
 public void Remove(PlotUpgrade upgrade)
 {
     upgrades.Remove(upgrade);
     upgrade.Remove(plot);
 }
예제 #6
0
 public void Add(PlotUpgrade upgrade)
 {
     upgrades.Add(upgrade);
     upgrade.Apply(plot.gameObject);
 }
예제 #7
0
 public static void Write_Upgrade_Data_Value(PlotID pid, PlotUpgrade upgrade, string key, byte[] value)
 {
     Write_Upgrade_Data_Value(pid, upgrade.ID, key, value);
 }