private void SetupRepairButton(AbstractBuildingTile tile, AbstractMarketManager manager) { int price = tile.Building.Data.RepairCost; BuildingHealth buildingHealth = tile.Building.GetComponent <BuildingHealth>(); float percentage = buildingHealth.CurrentBuildingHealthPercentage; price = (int)((1 - percentage) * price); repairText.text = price.ToString(); if (!CanAffort(price)) { BlockButton(btnRepair); return; } UnblockButton(btnRepair); SetButton(btnRepair, OnClick); void OnClick() { ReduceMoney(price); buildingHealth.ResetBuildingHealth(); manager.CloseMarket(); } }
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(); } }
private void SetupUpgradeButtons(AbstractBuildingTile tile, AbstractMarketManager manager) { BuildingUpgrade buildingUpgrade = tile.Building.GetComponent <BuildingUpgrade>(); SetTierText(tile, buildingUpgrade); if (!buildingUpgrade.CanUpgrade()) { btnUpgrade.ForEach(BlockButton); upgradeText.text = LanguageUtil.GetJsonString(maxUpgradeKey); return; } int price = tile.Building.UpgradeCost; upgradeText.text = price.ToString(); if (!CanAffort(price)) { btnUpgrade.ForEach(BlockButton); return; } btnUpgrade.ForEach(UnblockButton); btnUpgrade.ForEach(Setup); void Setup(Button button) { SetButton(button, OnClick); void OnClick() { ReduceMoney(price); buildingUpgrade.Upgrade(); manager.CloseMarket(); } } }
protected virtual void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { manager.CloseMarket(); }