private void SetupDemolishButton(AbstractBuildingTile tile, AbstractMarketManager manager) { int price = tile.GetCurrentSoilData().RemoveCost; demolishText.text = price.ToString(); if (!CanAffort(price) || tile.HasFoundation) { BlockButton(btnDemolish, true); return; } BlockButton(btnDemolish, false); SetButton(btnDemolish, OnClick); void OnClick() { confirmDemolishPopup.ShowPopUp(OnConfirmDemolish); } void OnConfirmDemolish() { ReduceMoney(price); tile.RemoveSoil(); manager.CloseMarket(); } }
private void SetSoilButton(ButtonData buttonData) { int price = selectedTile.GetCurrentSoilData().RepairCost; float percentage = buildingHealth.CurrentSoilHealthPercentage; price = (int)((1 - percentage) * price); buttonData.PriceText.text = price.ToString(); buildingHealth.SetSoilHealthBar(buttonData.healthBar); Button button = buttonData.Button; if (!CanAffort(price)) { BlockButton(button, true); return; } BlockButton(button, false); SetButton(button, OnClick); void OnClick() { ReduceMoney(price); buildingHealth.ResetSoilHealth(); } }
private void SetupRepairButton(AbstractBuildingTile tile, AbstractMarketManager manager) { int price = tile.GetCurrentSoilData().RepairCost; BuildingHealth buildingHealth = tile.Building.GetComponent <BuildingHealth>(); float percentage = buildingHealth.CurrentSoilHealthPercentage; 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.ResetSoilHealth(); manager.CloseMarket(); } }