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 SetInfo(BuildingInfo info) { _currentInfo = info as ProduceBuildingInfo; if (_currentInfo == null) { return; } if (_currentInfo.BuildingType == CityBuildingType.HOUSE) { _imageIcon.sprite = ResourceManager.Instance.GetResIcon(ResourceType.MONEY); } else if (_currentInfo.BuildingType == CityBuildingType.WOOD) { _imageIcon.sprite = ResourceManager.Instance.GetResIcon(ResourceType.WOOD); } else if (_currentInfo.BuildingType == CityBuildingType.STONE) { _imageIcon.sprite = ResourceManager.Instance.GetResIcon(ResourceType.STONE); } // 点击会隐藏资源图标,无论有没有收集完毕,即使没有收集完毕,在一定时间内也不会重复显示图标 if (_currentInfo.IsInBuilding() || _currentInfo.LastClickTime.IsValid() && _currentInfo.LastClickTime.GetTime() <= GameConfig.PRODUCE_REWARD_INTERVAL) { gameObject.SetActive(false); } else { gameObject.SetActive(_currentInfo.GetCurrentProduceValue() > 0); } UpdateIconColor(); }
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 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()); } }
public void UpdatePanel() { BuildingInfo info = CityManager.Instance.GetBuildingByConfigID(_buildingCfgID); ProduceBuildingInfo pbinfo = info as ProduceBuildingInfo; if (pbinfo == null) { return; } if (_produceInfoPanel != null) { if (!_produceInfoPanel.gameObject.activeInHierarchy && !info.IsInBuilding() && pbinfo.GetCurrentProduceValue() > 0 && (!_currentInfo.LastClickTime.IsValid() || pbinfo.LastClickTime.GetTime() >= GameConfig.PRODUCE_REWARD_INTERVAL)) { _produceInfoPanel.Show(true); } _produceInfoPanel.UpdateIconColor(); } }