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 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(); } }
protected override void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager) { if (tile.HasDebris) // Tile has debris { SetBars(null); HasDebris(tile, manager); return; } if (tile.HasBuilding) // Tile has building, foundation and soil { SetBars(tile); HasBuilding(tile, manager); return; } // Healthbars only matter in case of a building SetBars(null); if (tile.HasFoundation) // Tile has foundation and soil { HasFoundation(tile, manager); return; } if (tile.HasSoil) // Tile has soil { HasSoil(tile, manager); return; } // The tile is empty HandleEmpty(tile, manager); }
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 HasDebris(AbstractBuildingTile tile, AbstractMarketManager manager) { BlockButtons(true, true, true); screenData.HasDebris = true; SetText("Blocked by Debris!", "Blocked by Debris!", "Blocked by Debris!"); }
protected override void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager) { SerializableEnumDictionary <BuildingType, BuyButtonData> buildingButtons = GetComponent <BuildingBuyScreen>().GetbuyButtonData(); foreach (KeyValuePair <BuildingType, BuyButtonData> buttonData in buildingButtons) { SetText(buttonData, tile); } }
private void HandleEmpty(AbstractBuildingTile tile, AbstractMarketManager manager) { BlockButtons(true, true, false); SetButton(soilButton, () => manager.PutScreenInFocus(manager.Screens.SoilBuyScreen)); screenData.SetBuildingFoundationSoil(false, false, false); SetText("NoBuilding!", "NoFoundation!", "NoSoil!"); }
private void HasSoil(AbstractBuildingTile tile, AbstractMarketManager manager) { BlockButtons(true, false, false); SetButton(foundationButton, () => manager.PutScreenInFocus(manager.Screens.FoundationBuyScreen)); SetButton(soilButton, () => manager.PutScreenInFocus(manager.Screens.SoilManageScreen)); screenData.SetBuildingFoundationSoil(false, false, true); SetText("NoBuilding!", "NoFoundation!", tile.GetSoilType().ToString()); }
private void HasBuilding(AbstractBuildingTile tile, AbstractMarketManager manager) { BlockButtons(false, false, false); SetButton(buildingButton, () => manager.PutScreenInFocus(manager.Screens.BuildingManageScreen)); SetButton(foundationButton, () => manager.PutScreenInFocus(manager.Screens.FoundationManageScreen)); SetButton(soilButton, () => manager.PutScreenInFocus(manager.Screens.SoilManageScreen)); screenData.SetBuildingFoundationSoil(true, true, true); SetText(tile.Building.BuildingType.ToString(), tile.GetFoundationType().ToString(), tile.GetSoilType().ToString()); }
protected override void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager) { if (tile.HasBuilding) { BlockButton(btnRepair, false); SetupRepairButton(tile, manager); } else { BlockButton(btnRepair, true); } SetupDemolishButton(tile, manager); }
protected override void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager) { SetSpriteToCurrent(currentBuildingSprite, tile.Building); BuildingUpgrade buildingUpgrade = tile.Building.GetComponent <BuildingUpgrade>(); if (buildingUpgrade.CanUpgrade()) { SetSpriteToNext(nextBuildingSprite, tile.Building); return; } SetSpriteToCurrent(nextBuildingSprite, tile.Building); }
private void SetupBuyButton(AbstractBuildingTile tile, AbstractMarketManager manager) { int price = GetPrice(tile); if (!CanAffort(price)) { BlockButton(btnBuy, true); return; } BlockButton(btnBuy, false); SetButton(btnBuy, OnClick); void OnClick() { ReduceMoney(price); BuyButtonClick(tile, manager); } }
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 override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { base.BuyButtonClick(tile, manager); switch (selectedPowerup) { case PowerUpType.AvoidMonster: PowerUpManager.Instance.AvoidMonsters++; break; case PowerUpType.FixProblems: PowerUpManager.Instance.FixProblems++; break; case PowerUpType.AvoidWeatherEvent: PowerUpManager.Instance.AvoidWeather++; break; default: throw new ArgumentOutOfRangeException(); } }
private void SetupTypeButtons(AbstractBuildingTile tile, AbstractMarketManager manager) { TBuyType[] unlocked = GetUnlockedTypes(); foreach (KeyValuePair <TBuyType, BuyButtonData> pair in buttonDataPerBuyType) { Button button = pair.Value.Button; if (!unlocked.Contains(pair.Key)) { BlockButton(button, true); continue; } if (selectedButtonDatum == null) { Select(tile, pair, manager); } BlockButton(button, false); SetButton(button, () => Select(tile, pair, manager)); } }
protected override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { EventManager.Instance.RaiseEvent(new BuyPlotEvent()); tile.SpawnSoil(); base.BuyButtonClick(tile, manager); }
/// <summary> /// Initialize the screen /// </summary> public void SetUI(AbstractBuildingTile tile, AbstractMarketManager manager) { SetupScreen(tile, manager); ActivateExtensions(tile, manager); }
protected override void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager) { SetupUpgradeButtons(tile, manager); SetupRepairButton(tile, manager); SetupDemolishButton(tile, manager); }
protected abstract void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager);
private void Select(AbstractBuildingTile tile, SerializableKeyValuePair <TBuyType, BuyButtonData> pair, AbstractMarketManager manager) { // if we select the selected button, don't do anything if (selectedButtonDatum != null && selectedButtonDatum.Value.Equals(pair)) { return; } BuyButtonData buyButtondatum = pair.Value; SetTextActive(buyButtondatum, true); btnBuy.transform.position = buyButtondatum.Button.transform.position; OnSelectBuyButton(tile, pair.Key); Deselect(selectedButtonDatum); selectedButtonDatum = pair; SetupBuyButton(tile, manager); }
private void ActivateExtensions(AbstractBuildingTile tile, AbstractMarketManager manager) { Extensions?.Invoke(tile, manager); }
protected virtual void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { manager.CloseMarket(); }
protected override void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager) { selectedButtonDatum = null; SetupTypeButtons(tile, manager); }
protected abstract void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager);
protected override void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager) { SetSprites(tile, GetComponent <MainScreen>().GetScreenData(tile)); }
protected override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { tile.SpawnBuilding(true); base.BuyButtonClick(tile, manager); }
protected override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager) { tile.SpawnFoundation(); base.BuyButtonClick(tile, manager); EventManager.Instance.RaiseEvent(new FoundationBuildEvent()); }
protected override void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager) { informationText.text = LanguageUtil.GetJsonString(jsonKeys[GetType(tile)]); }