예제 #1
0
    public BuildingInfo CreateBuilding(int cfgID)
    {
        BuildingConstConfig cfg = BuildingConstConfigLoader.GetConfig(cfgID);

        if (cfg != null)
        {
            CityBuildingType bt = (CityBuildingType)cfg.BuildingType;
            switch (bt)
            {
            case CityBuildingType.HOUSE:
            case CityBuildingType.WOOD:
            case CityBuildingType.STONE:
                return(new ProduceBuildingInfo());

            case CityBuildingType.MONEY_STORAGE:
            case CityBuildingType.STONE_STORAGE:
            case CityBuildingType.WOOD_STORAGE:
            case CityBuildingType.PALACE:
            case CityBuildingType.SMITHY:
            case CityBuildingType.COLLEGE:
                return(new BuildingInfo());

            case CityBuildingType.TRAIN:
                return(new TrainBuildingInfo());

            case CityBuildingType.TROOP:
                return(new TroopBuildingInfo());
            }
        }

        return(null);
    }
예제 #2
0
    // 获取建筑图像
    public Sprite GetBuildingrImage(int cfgID)
    {
        BuildingConstConfig cfg = BuildingConstConfigLoader.GetConfig(cfgID);

        if (cfg != null)
        {
            return(GetSprite("Texture/BuildingIcon/" + cfg.BuildingIcon));
        }
        return(GetSprite("Texture/BuildingIcon/UI_bingying"));
    }
예제 #3
0
    public void OnClick()
    {
        if (_currentInfo == null)
        {
            // 如果尚未获得此建筑,建筑尚未解锁,则提示解锁等级
            BuildingConstConfig cfg = BuildingConstConfigLoader.GetConfig(_buildingCfgID);
            if (cfg != null)
            {
                UIUtil.ShowMsgFormat("MSG_CITY_BUILDING_UNLOCK", cfg.UnlockHomeLevelDemand);
            }
        }
        else
        {
            if (_currentInfo.IsInBuilding())
            {
                UIManager.Instance.OpenWindow <UICityBuildingMenuView>(_currentInfo, this, Parent);
                return;
            }

            if (_currentInfo.BuildingType == CityBuildingType.TRAIN)
            {
                TrainBuildingInfo tbinfo = _currentInfo as TrainBuildingInfo;
                if (tbinfo != null && tbinfo.IsTrainingSoldier())
                {
                    // 校场正在训练士兵
                    UIManager.Instance.OpenWindow <UICityTrainMenuView>(_currentInfo, this, Parent);
                    return;
                }
            }
            else if (_currentInfo.BuildingType == CityBuildingType.TROOP)
            {
                // 兵营正在生产士兵
                TroopBuildingInfo tbinfo = _currentInfo as TroopBuildingInfo;
                if (tbinfo != null && tbinfo.IsProducingSoldier())
                {
                    UIManager.Instance.OpenWindow <UICityBuildingMenuView>(_currentInfo, this, Parent);
                    return;
                }
            }

            // 正常逻辑
            switch (_currentInfo.BuildingType)
            {
            case CityBuildingType.HOUSE:
            case CityBuildingType.WOOD:
            case CityBuildingType.STONE:
                OnClickProduce();
                break;

            case CityBuildingType.MONEY_STORAGE:
            case CityBuildingType.STONE_STORAGE:
            case CityBuildingType.WOOD_STORAGE:
                OnClickBuilding();
                break;

            case CityBuildingType.PALACE:
                OnClickPalace();
                break;

            case CityBuildingType.TRAIN:
                OnClickTrain();
                break;

            case CityBuildingType.TROOP:
                OnClickTroop();
                break;

            case CityBuildingType.SMITHY:
                OnClickSmithy();
                break;

            case CityBuildingType.COLLEGE:
                OnClickCollege();
                break;
            }
        }
    }