コード例 #1
0
    public UPGRADE_PART_RESULT CanUpgradePart(int index)
    {
        DataUnitPart mainDataPart = GetDataParts()[0];
        DataUnitPart dataPart     = GetDataParts()[index];

        Trace.trace("GetPartLevelMax(index) " + GetPartLevelMax(index), Trace.CHANNEL.UI);
        if (dataPart.level + 1 > GetPartLevelMax(index))
        {
            return(UPGRADE_PART_RESULT.MAX_LEVEL);
        }
        if (dataPart.mainLevel > mainDataPart.level)
        {
            return(UPGRADE_PART_RESULT.NEED_MAIN_LEVEL);
        }
        if (index != 0)
        {
            if (mainDataPart.level < dataPart.level + 1)
            {
                return(UPGRADE_PART_RESULT.NEED_MAIN_LEVEL);
            }
        }
        else
        {
            int userLevel = InstancePlayer.instance.model_User.honorLevel;
            if (mainDataPart.level + 1 > userLevel)
            {
                return(UPGRADE_PART_RESULT.NEED_USER_LEVEL);
            }
        }


        ConnectionValidateHelper.CostCheck r = ConnectionValidateHelper.IsEnoughCost(dataPart.cost);
        if (r != ConnectionValidateHelper.CostCheck.OK)
        {
            return(UPGRADE_PART_RESULT.NEED_RESOURCE);
        }

        return(UPGRADE_PART_RESULT.OK);
    }
コード例 #2
0
    void UpdateUI()
    {
        if (_unitData != null)
        {
            _model_User  = InstancePlayer.instance.model_User;
            _model_Units = InstancePlayer.instance.model_User.unlockUnits;
            _dataUnit    = _unitData.unitData;

            _TankNameLabel.text  = _unitData.unitData.name.ToString();
            _TankNameLabel.color = _unitData.nameColor;
//			Trace.trace("_unitData.nameColor " +  _unitData.nameColor ,Trace.CHANNEL.UI);
            _iconBg.spriteName = _unitData.iconBgName;
            _icon.SetUnitSmallTexture(_unitData.id);
            if (_unitData.isUnLock)
            {
                _canResearch_Sprite.gameObject.SetActive(false);
            }
            else
            {
                _canResearch_Sprite.gameObject.SetActive(_unitData.isCanUnlock);
            }

            _format_Sprite.gameObject.SetActive(_unitData.isFormation);

            if (_unitData.isUnLock)
            {
                _model_Units.TryGetValue(_dataUnit.id, out _model_unit);
            }
            _lock_Container.gameObject.SetActive(!_unitData.isUnLock);
            _unlock_Container.gameObject.SetActive(_unitData.isUnLock);

            if (_model_unit != null && _model_unit.onProduce > 0)
            {
                if (_model_unit.produceLeftTime == 0)
                {
                    _productBtn.gameObject.SetActive(false);
                    _repairBtn.gameObject.SetActive(false);
                    _harvestBtn.gameObject.SetActive(true);
                    _speed_Container.gameObject.SetActive(false);
                }
                else
                {
                    _productBtn.gameObject.SetActive(false);
                    _repairBtn.gameObject.SetActive(false);
                    _harvestBtn.gameObject.SetActive(false);
                    _speed_Container.gameObject.SetActive(true);
                }
            }
            else
            {
                _productBtn.gameObject.SetActive(true);
                _repairBtn.gameObject.SetActive(true);
                _harvestBtn.gameObject.SetActive(false);
                _speed_Container.gameObject.SetActive(false);
            }
//
//			bool isSpeedShow ;
//			if(_model_unit != null && _model_unit.produceLeftTime > 0)
//			{
//				isSpeedShow = true;
//			}
//			else
//			{
//				isSpeedShow = false;
//			}
//			_speed_Container.gameObject.SetActive(isSpeedShow);
//			_productBtn.gameObject.SetActive(!isSpeedShow);
//			_repairBtn.gameObject.SetActive(!isSpeedShow);

            //坦克研发红点
            _researchRedPoint.gameObject.SetActive(_unitData.isCanUnlock);
            _researchBtn.isEnabled = _unitData.isCanUnlock;
//			所需图纸个数
            _needPaperValue_Label.text = _unitData.unitData.chipCount.ToString();
            Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup;
            Item            item            = model_itemGroup.QueryItem(_unitData.unitData.chipId);
//			拥有的个数
            _currentValue_Label.text = item.num.ToString();
            // 生产的小红点
            ConnectionValidateHelper.CostCheck costCheck = ConnectionValidateHelper.IsEnoughCost(_dataUnit.cost);
            if (costCheck == ConnectionValidateHelper.CostCheck.OK)
            {
                _product_redPoint.gameObject.SetActive(true);
            }
            else
            {
                _product_redPoint.gameObject.SetActive(false);
            }

            // Clear CD Need Cash
            if (_model_unit != null)
            {
                _Timer_Colored_Slider.value = (_model_unit.produceLeftTime) / (float)_model_unit.produceTotalTime;
                _timeLabel.text             = UIHelper.setTimeDHMS(_model_unit.produceLeftTime);
                float needCash = _model_User.model_InitialConfig.GetClearUnitCDCash(_model_unit.produceLeftTime);
                _speedCoinLabel.text = (int)needCash + "";
            }
        }
    }