Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
    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();
    }
Exemplo n.º 3
0
    public void Show(bool show)
    {
        if (show && _currentInfo.IsInBuilding())
        {
            return;
        }
        gameObject.SetActive(show);

        UpdateIconColor();
    }