예제 #1
0
    public void OnClickProduceIcon()
    {
        ProduceBuildingInfo pbinfo = _currentInfo as ProduceBuildingInfo;

        if (pbinfo == null)
        {
            return;
        }

        if (!pbinfo.IsProduceFull() && pbinfo.GetCurrentProduceValue() > 0)
        {
            // 如果资源未满,并且有产出 则请求收货
            CityManager.Instance.RequestHarvest(_currentInfo.EntityID);
        }
        else
        {
            // 资源已满
            UIUtil.ShowMsgFormat("UI_MSG_RES_FULL", _currentInfo.GetContainerBuildingName(), _currentInfo.GetResName());
        }
    }
예제 #2
0
    private void SetInfo(BuildingInfo info)
    {
        _currentInfo = info;
        if (_currentInfo == null)
        {
            return;
        }

        _title.text           = info.Cfg.BuildingName;
        _txtLevel.text        = Str.Format("UI_LEVEL", info.Level);
        _desc.text            = info.Cfg.BuildingDescription;
        _buildingImage.sprite = ResourceManager.Instance.GetBuildingIcon(info.ConfigID);

        // 如果建筑正在升级,不显示升级按钮
        _btnLevelUp.gameObject.SetActive(!_currentInfo.IsInBuilding());

        _maxContainValue.text = _currentInfo.GetMaxContainValue().ToString();
        _levelupTime.text     = Utils.GetCountDownString(Utils.GetSeconds(_currentInfo.CfgLevel.UpgradeTime));

        switch (_currentInfo.BuildingType)
        {
        case CityBuildingType.HOUSE:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.MONEY);
            _imageProduce.sprite    = ResourceManager.Instance.GetResIcon(ResourceType.MONEY);
            break;

        case CityBuildingType.STONE:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.STONE);
            _imageProduce.sprite    = ResourceManager.Instance.GetResIcon(ResourceType.STONE);
            break;

        case CityBuildingType.WOOD:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.WOOD);
            _imageProduce.sprite    = ResourceManager.Instance.GetResIcon(ResourceType.WOOD);
            break;

        case CityBuildingType.MONEY_STORAGE:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.MONEY);
            break;

        case CityBuildingType.STONE_STORAGE:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.STONE);
            break;

        case CityBuildingType.WOOD_STORAGE:
            _imageMaxContain.sprite = ResourceManager.Instance.GetResIcon(ResourceType.WOOD);
            break;
        }

        ProduceBuildingInfo pbinfo = _currentInfo as ProduceBuildingInfo;

        if (pbinfo != null)
        {
            _produceValue.text = pbinfo.GetUnitProduceValue().ToString();

            if (pbinfo.IsProduceFull())
            {
                // 资源满了,提示升级建筑
                _txtFull.text = Str.Format("UI_MSG_RES_FULL", _currentInfo.GetContainerBuildingName(), _currentInfo.GetResName());
                _txtFull.gameObject.SetActive(true);
            }
            else
            {
                _txtFull.gameObject.SetActive(false);
            }

            _txtMaxContain.text = Str.Get("UI_CITY_BUILDING_MAX_CONTAIN");
            _txtProduceText.gameObject.SetActive(true);
        }
        else
        {
            _txtProduceText.gameObject.SetActive(false);
            _txtFull.gameObject.SetActive(false);
            _txtMaxContain.text = Str.Get("UI_CITY_BUILDING_CONTAIN");
        }
    }