Пример #1
0
        private static Sisco_Return onSpawn_PlotUpgrades_Kiosk(ref object sender, ref object[] args, ref object return_value)
        {
            LandPlot.Id kind = (LandPlot.Id)args[0];
#if !SR_VANILLA
            LandPlotUI         kiosk   = sender as LandPlotUI;
            LandPlot           plot    = kiosk.Get_LandPlot();
            PlotUpgradeTracker tracker = plot.GetComponent <PlotUpgradeTracker>();
            if (tracker == null)
            {
                tracker = plot.gameObject.AddComponent <PlotUpgradeTracker>();
            }


            GameObject panel = return_value as GameObject;
            var        ui    = panel.GetComponent <PurchaseUI>();

            foreach (PlotUpgrade up in ALL[Upgrade_Type.PLOT_UPGRADE].Values)
            {
                if (up.Kind != kind)
                {
                    continue;
                }
                bool can_buy = up.CanBuy(tracker);
                ui.AddButton(new PurchaseUI.Purchasable(up.Name, up.Sprite, up.PreviewSprite, up.Description, up.Cost, new PediaDirector.Id?(), new UnityAction(() => { up.Purchase(kiosk.gameObject); }), can_buy));
            }
#endif
            return(null);
        }
Пример #2
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);
        }
        internal static Sisco_Return Ext_Demolish_Plot_Upgrade(ref object sender, ref object[] args, ref object return_value)
        {
#if !SR_VANILLA
            LandPlot.Id kind = Get_Plot_ID_From_Upgrades_UI_Class(sender);
            LandPlotUI  ui   = sender as LandPlotUI;
            LandPlot    plot = ui.Get_LandPlot();
            return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Demolished_Land_Plot, plot, ref return_value, new object[] { kind })));
#else
            return(null);
#endif
        }