Пример #1
0
        private void SetFoundationButton(ButtonData buttonData)
        {
            int price = selectedTile.GetCurrentFoundationData().RepairCost;

            float percentage = buildingHealth.CurrentFoundationHealthPercentage;

            price = (int)((1 - percentage) * price);

            buttonData.PriceText.text = price.ToString();
            buildingHealth.SetFoundationHealthBar(buttonData.healthBar);

            Button button = buttonData.Button;

            if (!CanAffort(price))
            {
                BlockButton(button, true);
                return;
            }

            BlockButton(button, false);
            SetButton(button, OnClick);

            void OnClick()
            {
                ReduceMoney(price);
                buildingHealth.ResetFoundationHealth();
            }
        }
        private void SetupRepairButton(AbstractBuildingTile tile, AbstractMarketManager manager)
        {
            int            price          = tile.GetCurrentFoundationData().RepairCost;
            BuildingHealth buildingHealth = tile.Building.GetComponent <BuildingHealth>();

            float percentage = buildingHealth.CurrentFoundationHealthPercentage;

            price = (int)((1 - percentage) * price);

            repairText.text = price.ToString();

            if (!CanAffort(price))
            {
                BlockButton(btnRepair, true);
                return;
            }

            BlockButton(btnRepair, false);

            SetButton(btnRepair, OnClick);

            void OnClick()
            {
                ReduceMoney(price);
                buildingHealth.ResetFoundationHealth();
                manager.CloseMarket();
            }
        }