private void OnClickProduce() { ProduceBuildingInfo pbinfo = _currentInfo as ProduceBuildingInfo; if (pbinfo == null) { return; } if (!pbinfo.IsProduceFull() && pbinfo.GetCurrentProduceValue() > 0 && !pbinfo.IsInBuilding()) { // 如果资源未满,并且有产出 则请求收货 Log.Info("收集资源: {0}", pbinfo.GetCurrentProduceValue()); CityManager.Instance.RequestHarvest(_currentInfo.EntityID); if (pbinfo.BuildingType == CityBuildingType.WOOD) { EventDispatcher.TriggerEvent(EventID.EVENT_CITY_AWARD_WOOD); } else if (pbinfo.BuildingType == CityBuildingType.STONE) { EventDispatcher.TriggerEvent(EventID.EVENT_CITY_AWARD_STONE); } } else { // 点击界面,则隐藏资源收获图标 EventDispatcher.TriggerEvent(EventID.EVENT_CITY_BUILDING_SHOW_PRODUCE_PANEL, pbinfo.EntityID, false); // 如果没有产出,则打开信息界面,此为升级等功能入口 UIManager.Instance.OpenWindow <UICityBuildingUplevelView>(_currentInfo); } }
public void OnClick() { if (gameObject.activeInHierarchy) { _currentInfo.LastClickTime.SetTime(0); } Show(false); ProduceBuildingInfo pbinfo = _currentInfo as ProduceBuildingInfo; if (pbinfo == null) { return; } if (!pbinfo.IsProduceFull() && pbinfo.GetCurrentProduceValue() > 0) { // 如果资源未满,并且有产出 则请求收货 CityManager.Instance.RequestHarvest(_currentInfo.EntityID); if (pbinfo.BuildingType == CityBuildingType.WOOD) { EventDispatcher.TriggerEvent(EventID.EVENT_CITY_AWARD_WOOD); } else if (pbinfo.BuildingType == CityBuildingType.STONE) { EventDispatcher.TriggerEvent(EventID.EVENT_CITY_AWARD_STONE); } } else { // 资源已满 UIUtil.ShowMsgFormat("UI_MSG_RES_FULL", _currentInfo.GetContainerBuildingName(), _currentInfo.GetResName()); } }
public void UpdateIconColor() { if (_currentInfo.IsProduceFull()) { _imageIcon.color = Color.red; } else { _imageIcon.color = Color.white; } }
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()); } }
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"); } }