Exemple #1
0
    void OnUpradeAllWall()
    {
        if (SceneManager.Instance.SelectedAllWallList.Count > 1)
        {
            for (int i = 0; i < SceneManager.Instance.SelectedAllWallList.Count; i++)
            {
                if (!SceneManager.Instance.SelectedAllWallList[i].IsBuild || !SceneManager.Instance.SelectedAllWallList[i].EnableCreate)
                {
                    return;
                }
            }
            this.ResetBuildingArrow();
            UIManager.Instance.HidePopuBtnByCurrentSelect(false);
            List <WallBehavior> wallBehaviorList = SceneManager.Instance.SelectedAllWallList;
            //wallBehaviorList.Sort(delegate(WallBehavior a, WallBehavior b) { return a.BuildingLogicData.Level - b.BuildingLogicData.Level; });
            wallBehaviorList.Sort((WallBehavior a, WallBehavior b) => a.BuildingLogicData.Level - b.BuildingLogicData.Level);
            int upgradeCount = 0;
            int upgradeStep  = 0;
            int wallLowLevel = wallBehaviorList[0].BuildingLogicData.Level;
            for (int i = 0; i < wallBehaviorList.Count; i++)
            {
                if (wallBehaviorList[i].BuildingLogicData.Level == wallLowLevel &&
                    wallBehaviorList[i].BuildingLogicData.Level <= LogicController.Instance.CurrentCityHallLevel - wallBehaviorList[i].BuildingLogicData.UpgradeStep &&
                    LogicController.Instance.IdleBuilderNumber > 0 &&
                    SystemFunction.UpgradeCostBalance(wallBehaviorList[i].BuildingLogicData).Count == 0)
                {
                    SceneManager.Instance.CreateUpgradeFX(wallBehaviorList[i]);
                    LogicController.Instance.BuyUpgradeWall(wallBehaviorList[i].BuildingLogicData.BuildingIdentity.buildingNO);
                    //SceneManager.Instance.CreateFX(wallBehaviorList[i].BuildingBehavior.BuildingAnchor, FxType.Upgrade1x1, false);
                    wallBehaviorList[i].BuildingCommon.ConstructBuilding();
                    upgradeStep = wallBehaviorList[i].BuildingLogicData.UpgradeStep;
                    upgradeCount++;
                }
                else
                {
                    wallBehaviorList[i].SetCellVisible(false);
                    wallBehaviorList[i].SetArrowState(false);
                    wallBehaviorList[i].IsClick = false;
                    wallBehaviorList[i].OnActiveBuildingFX(false);
                }
            }
            if (upgradeCount > 0)
            {
                UIErrorMessage.Instance.ErrorMessage(string.Format(StringConstants.ERROR_MESSAGE[24], upgradeCount.ToString(), wallLowLevel.ToString(), (wallLowLevel + upgradeStep).ToString()), Color.white);
            }
            //UIErrorMessage.Instance.ErrorMessage(24, upgradeCount.ToString(), wallLowLevel.ToString(), (wallLowLevel + upgradeStep).ToString());
            else
            {
                UIErrorMessage.Instance.ErrorMessage(23);
            }

            SceneManager.Instance.ClearAllWallList();
        }
    }
    void ConstructEvent(Action function)
    {
        BuildingConfigData         buildingConfigData = ConfigInterface.Instance.BuildingConfigHelper.GetBuildingData(this.BuildingBehavior.BuildingType, 0);
        Dictionary <CostType, int> costBalance        = this.BuildingBehavior.Created ? SystemFunction.UpgradeCostBalance(this.BuildingLogicData) : SystemFunction.UpgradeCosBalance(buildingConfigData);
        Dictionary <CostType, int> costTotal          = this.BuildingBehavior.Created ? SystemFunction.UpgradeTotalCost(this.BuildingLogicData) : SystemFunction.UpgradeTotalCost(buildingConfigData);
        int costGem = this.BuildingBehavior.Created ? this.BuildingLogicData.UpgradeGem : buildingConfigData.UpgradeGem;

        if (costBalance.Count > 0)
        {
            int costBalanceGem = SystemFunction.ResourceConvertToGem(costBalance);
            //int costResourceToGem = SystemFunction.ResourceConvertToGem(costTotal) - costGem;

            string resourceContext = SystemFunction.BuyReusoureContext(costBalance);
            UIManager.Instance.UIWindowCostPrompt.ShowWindow(costBalanceGem, resourceContext, SystemFunction.BuyReusoureTitle(costBalance));
            UIManager.Instance.UIWindowCostPrompt.UnRegistDelegate();
            UIManager.Instance.UIWindowCostPrompt.Click += () =>
            {
                if (SystemFunction.CostUplimitCheck(costTotal[CostType.Gold], costTotal[CostType.Food], costTotal[CostType.Oil]))
                {
                    if (LogicController.Instance.PlayerData.CurrentStoreGem - costBalanceGem /*costResourceToGem*/ < costGem)
                    {
                        print("宝石不足,去商店");
                        UIManager.Instance.UIWindowFocus = null;
                        //UIManager.Instance.UIButtonShopping.GoShopping();
                        UIManager.Instance.UISelectShopMenu.GoShopping();
                    }
                    else
                    {
                        print("宝石换资源!");
                        SystemFunction.BuyResources(costBalance);
                        function.Invoke();
                    }
                }
                else
                {
                    UIErrorMessage.Instance.ErrorMessage(16);
                }
            };
        }
        else
        {
            function.Invoke();
        }
    }