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(); } }
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(); } }