Exemplo n.º 1
0
        private void SetupDemolishButton(AbstractBuildingTile tile, AbstractMarketManager manager)
        {
            int price = tile.Building.Data.DestructionCost;

            demolishText.text = price.ToString();

            if (!CanAffort(price))
            {
                BlockButton(btnDemolish);
                return;
            }

            UnblockButton(btnDemolish);

            SetButton(btnDemolish, OnClick);

            void OnClick()
            {
                confirmDemolishPopup.ShowPopUp(OnConfirmDemolish);
            }

            void OnConfirmDemolish()
            {
                tile.Building.RemoveBuilding();
                tile.SpawnSoil();
                tile.SpawnFoundation();
                manager.CloseMarket();
            }
        }
        private void SetupDemolishButton(AbstractBuildingTile tile, AbstractMarketManager manager)
        {
            int price = tile.GetCurrentFoundationData().DestructionCost;

            demolishText.text = price.ToString();

            if (!CanAffort(price) || tile.HasBuilding)
            {
                BlockButton(btnDemolish, true);
                return;
            }

            BlockButton(btnDemolish, false);

            SetButton(btnDemolish, OnClick);

            void OnClick()
            {
                confirmDemolishPopup.ShowPopUp(OnConfirmDemolish);
            }

            void OnConfirmDemolish()
            {
                ReduceMoney(price);

                tile.RemoveFoundation();
                manager.CloseMarket();
            }
        }