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();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        private void HasDebris(AbstractBuildingTile tile, AbstractMarketManager manager)
        {
            BlockButtons(true, true, true);

            screenData.HasDebris = true;

            SetText("Blocked by Debris!", "Blocked by Debris!", "Blocked by Debris!");
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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!");
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 13
0
        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();
                }
            }
        }
Ejemplo n.º 14
0
        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));
            }
        }
Ejemplo n.º 16
0
 protected override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager)
 {
     EventManager.Instance.RaiseEvent(new BuyPlotEvent());
     tile.SpawnSoil();
     base.BuyButtonClick(tile, manager);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initialize the screen
 /// </summary>
 public void SetUI(AbstractBuildingTile tile, AbstractMarketManager manager)
 {
     SetupScreen(tile, manager);
     ActivateExtensions(tile, manager);
 }
Ejemplo n.º 18
0
 protected override void SetupScreen(AbstractBuildingTile tile, AbstractMarketManager manager)
 {
     SetupUpgradeButtons(tile, manager);
     SetupRepairButton(tile, manager);
     SetupDemolishButton(tile, manager);
 }
Ejemplo n.º 19
0
 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);
        }
Ejemplo n.º 21
0
 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);
Ejemplo n.º 25
0
 protected override void ActivateExtension(AbstractBuildingTile tile, AbstractMarketManager manager)
 {
     SetSprites(tile, GetComponent <MainScreen>().GetScreenData(tile));
 }
Ejemplo n.º 26
0
 protected override void BuyButtonClick(AbstractBuildingTile tile, AbstractMarketManager manager)
 {
     tile.SpawnBuilding(true);
     base.BuyButtonClick(tile, manager);
 }
Ejemplo n.º 27
0
 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)]);
 }