Пример #1
0
 void UpdateTime()
 {
     if (_currentInfo.IsInBuilding())
     {
         // 建筑正在升级
         int cd = _currentInfo.GetLevelUpCD();
         _prgTime.fillAmount = 1.0f * cd / Utils.GetSeconds(_currentInfo.CfgLevel.UpgradeTime);
         _textTime.text      = Utils.GetCountDownString(cd);
     }
     else if (_currentInfo.BuildingType == CityBuildingType.TROOP)
     {
         // 如果是兵营的话
         TroopBuildingInfo tbinfo = _currentInfo as TroopBuildingInfo;
         if (tbinfo != null && tbinfo.IsProducingSoldier())
         {
             // 如果正在生产士兵,则显示士兵头像
             int cd = tbinfo.GetProducingCD();
             _prgTime.fillAmount = 1.0f * cd / tbinfo.GetMaxProduceTime();
             _textTime.text      = Utils.GetCountDownString(cd);
         }
     }
     else if (_currentInfo.BuildingType == CityBuildingType.TRAIN)
     {
         TrainBuildingInfo tbinfo = _currentInfo as TrainBuildingInfo;
         if (tbinfo != null && tbinfo.IsTrainingSoldier())
         {
             int cd = tbinfo.GetTrainCD();
             _prgTime.fillAmount = 1.0f * cd / tbinfo.GetMaxTrainTime();
             _textTime.text      = Utils.GetCountDownString(cd);
         }
     }
 }
Пример #2
0
    private void SetInfo(BuildingInfo info)
    {
        _currentInfo = info;
        if (_currentInfo == null)
        {
            return;
        }

        _title.text    = _currentInfo.Cfg.BuildingName;// string.Format(Str.Get("UI_CITY_BUILDING_LEVELUP"), _currentInfo.Cfg.BuildingName, _currentInfo.Level + 1);
        _txtLevel.text = Str.Format("UI_LEVEL", info.Level);
        _desc.text     = _currentInfo.Cfg.BuildingDescription;

        _levupTime.text = Utils.GetCountDownString(_currentInfo.GetLevelUpCD());

        int quickCost = _currentInfo.GetQuickLevelUpCost(false);

        _levupNowCost.text  = quickCost.ToString();
        _levupNowCost.color = UserManager.Instance.Gold < quickCost ? Color.red : Color.white;

        _levupStoneCost.text  = _currentInfo.CfgLevel.CostStone.ToString();
        _levupStoneCost.color = UserManager.Instance.Stone < _currentInfo.CfgLevel.CostStone ? Color.red : Color.white;
        _levupWoodCost.text   = _currentInfo.CfgLevel.CostWood.ToString();
        _levupWoodCost.color  = UserManager.Instance.Wood < _currentInfo.CfgLevel.CostWood ? Color.red : Color.white;

        _curLevel.text = Str.Format("UI_SMITHY_EQUIP_LEVEL", GetEquipLevel(_currentInfo.Level));

        if (_currentInfo.IsMaxLevel())
        {
            _nextLevel.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            _nextLevel.transform.parent.gameObject.SetActive(true);
            _nextLevel.text = Str.Format("UI_SMITHY_EQUIP_LEVEL", GetEquipLevel(_currentInfo.Level));
        }
    }
Пример #3
0
    private void SetInfo(BuildingInfo info)
    {
        _currentInfo = info;
        if (_currentInfo == null)
        {
            return;
        }

        _title.text           = _currentInfo.Cfg.BuildingName;// string.Format(Str.Get("UI_CITY_BUILDING_LEVELUP"), _currentInfo.Cfg.BuildingName, _currentInfo.Level + 1);
        _maxContainValue.text = _currentInfo.GetMaxContainValue().ToString();
        _txtLevel.text        = Str.Format("UI_LEVEL", info.Level);
        _desc.text            = _currentInfo.Cfg.BuildingDescription;
        _buildingImage.sprite = ResourceManager.Instance.GetBuildingIcon(info.ConfigID);

        if (info.BuildingType == CityBuildingType.TROOP)
        {
            // 如果是兵营的话 显示最大人口
            _maxContainText.text = Str.Get("UI_CITY_BUILDING_MAX_SPACE");
        }
        else
        {
            // 显示最大容量
            _maxContainText.text = Str.Get("UI_CITY_BUILDING_MAX_CONTAIN");
        }

        int maxContainAddValue = _currentInfo.GetNextMaxContainValue();

        if (maxContainAddValue > 0)
        {
            _maxContainAddValue.gameObject.SetActive(true);
            _maxContainAddValue.text = string.Format("(+{0})", maxContainAddValue);
        }
        else
        {
            _maxContainAddValue.gameObject.SetActive(false);
        }

        _levupTime.text = Utils.GetCountDownString(_currentInfo.GetLevelUpCD());

        int quickCost = _currentInfo.GetQuickLevelUpCost(false);

        _levupNowCost.text  = quickCost.ToString();
        _levupNowCost.color = UserManager.Instance.Gold < quickCost ? Color.red : Color.white;

        _levupStoneCost.text  = _currentInfo.CfgLevel.CostStone.ToString();
        _levupStoneCost.color = UserManager.Instance.Stone < _currentInfo.CfgLevel.CostStone ? Color.red : Color.white;
        _levupWoodCost.text   = _currentInfo.CfgLevel.CostWood.ToString();
        _levupWoodCost.color  = UserManager.Instance.Wood < _currentInfo.CfgLevel.CostWood ? Color.red : Color.white;

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

        case CityBuildingType.STONE:
            _maxContainImage.sprite = ResourceManager.Instance.GetResIcon(ResourceType.STONE);
            _produceImage.sprite    = ResourceManager.Instance.GetResIcon(ResourceType.STONE);
            break;

        case CityBuildingType.WOOD:
            _maxContainImage.sprite = ResourceManager.Instance.GetResIcon(ResourceType.WOOD);
            _produceImage.sprite    = ResourceManager.Instance.GetResIcon(ResourceType.WOOD);
            break;

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

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

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

        case CityBuildingType.TROOP:
            _maxContainImage.sprite = ResourceManager.Instance.GetResIcon(ResourceType.SOLDIER);
            break;
        }
        _maxContainImage.SetNativeSize();
        _produceImage.SetNativeSize();

        ProduceBuildingInfo pbinfo = _currentInfo as ProduceBuildingInfo;

        if (pbinfo != null)
        {
            // 资源生产建筑
            _productValue.text = pbinfo.GetUnitProduceValue().ToString();

            int produceAddValue = pbinfo.GetNextProduceValue();
            if (produceAddValue > 0)
            {
                _productAddValue.gameObject.SetActive(true);
                _productAddValue.text = string.Format("(+{0})", produceAddValue);
            }
            else
            {
                _productAddValue.gameObject.SetActive(false);
            }
        }
        else
        {
            _txtProductText.gameObject.SetActive(false);
            _levelUpText.transform.position = _txtProductText.transform.position;
        }
    }
    private void SetInfo(BuildingInfo info)
    {
        _currentInfo = info;
        if (_currentInfo == null)
        {
            return;
        }

        //_title.text = string.Format(Str.Get("UI_CITY_BUILDING_LEVELUP"), _currentInfo.Cfg.BuildingName, _currentInfo.Level + 1);
        if (_currentInfo.BuildingType == CityBuildingType.PALACE)
        {
            _buildingImage.sprite = ResourceManager.Instance.GetBuildingIcon(info.ConfigID);
            _imgTrain.gameObject.SetActive(false);
        }
        else if (_currentInfo.BuildingType == CityBuildingType.TRAIN)
        {
            _imgTrain.sprite = ResourceManager.Instance.GetBuildingIcon(info.ConfigID);
            _buildingImage.gameObject.SetActive(false);
        }

        _levupTime.text = Utils.GetCountDownString(_currentInfo.GetLevelUpCD());

        _title.text                = info.Cfg.BuildingName;
        _txtLevel.text             = Str.Format("UI_LEVEL", info.Level);
        _desc.text                 = info.Cfg.BuildingDescription;
        _maxContainValue.text      = _currentInfo.GetMaxContainValue().ToString();
        _maxContainValueWood.text  = _currentInfo.GetMaxContainValue().ToString();
        _maxContainValueStone.text = _currentInfo.GetMaxContainValue().ToString();

        if (_currentInfo.BuildingType == CityBuildingType.TRAIN)
        {
            _maxContainValue.transform.parent.gameObject.SetActive(false);
            _maxContainValueWood.transform.parent.gameObject.SetActive(false);
            _maxContainValueStone.transform.parent.gameObject.SetActive(false);
        }

        int quickCost = _currentInfo.GetQuickLevelUpCost(false);

        _levupNowCost.text  = quickCost.ToString();
        _levupNowCost.color = UserManager.Instance.Gold < quickCost ? Color.red : Color.white;

        _levupStoneCost.text  = _currentInfo.CfgLevel.CostStone.ToString();
        _levupStoneCost.color = UserManager.Instance.Stone < _currentInfo.CfgLevel.CostStone ? Color.red : Color.white;
        _levupWoodCost.text   = _currentInfo.CfgLevel.CostWood.ToString();
        _levupWoodCost.color  = UserManager.Instance.Wood < _currentInfo.CfgLevel.CostWood ? Color.red : Color.white;

        foreach (var item in _unlockBuildingBg)
        {
            item.gameObject.SetActive(false);
        }
        _unlockText.gameObject.SetActive(false);

        int index = 0;

        if (_currentInfo.BuildingType == CityBuildingType.TRAIN)
        {
            // 校场
            _unlockText.text = Str.Get("UI_CITY_BUILDING_UNLOCK_SOLDIER");
            foreach (var item in SoldierConfigLoader.Data)
            {
                if (_currentInfo.Level + 1 == item.Value.UnlockMilitaryDemand)
                {
                    // 如果升级后的校场等级是士兵的解锁等级
                    _unlockBuildingBg[index].gameObject.SetActive(true);
                    _unlockBuildingIcon[index].sprite = ResourceManager.Instance.GetSoldierIcon(item.Key);
                    _unlockBuildingName[index].text   = item.Value.SoldierName;
                    ++index;
                }
            }
        }
        else if (_currentInfo.BuildingType == CityBuildingType.PALACE)
        {
            // 主城
            _unlockText.text = Str.Get("UI_CITY_BUILDING_UNLOCK_BUILDING");

            foreach (var item in BuildingConstConfigLoader.Data)
            {
                if (_currentInfo.Level + 1 == item.Value.UnlockHomeLevelDemand)
                {
                    // 如果升级后的校场等级是士兵的解锁等级
                    _unlockBuildingBg[index].gameObject.SetActive(true);
                    _unlockBuildingIcon[index].sprite = ResourceManager.Instance.GetBuildingIcon(item.Key);
                    _unlockBuildingName[index].text   = item.Value.BuildingName;
                    ++index;
                }
            }
        }

        if (index > 0)
        {
            _unlockText.gameObject.SetActive(true);
        }
        else
        {
            //_textLevelUpTime.transform.localPosition = _unlockText.transform.localPosition;
        }
    }