void UpdateUI() { if (_itemData != null) { Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Item item = model_itemGroup.QueryItem(_itemData.id); _value_Label.text = item.num.ToString(); _itemName.color = _itemData.nameColor; _itemName.text = _itemData.itemData.name; _describe_Label.text = _itemData.itemData.desc; _itemiconbg.spriteName = _itemData.iconBgName; _itemicon.SetItemTexture(_itemData.id); } }
public ItemData InitItemData(DataItem dataItem) { if (dataItem != null) { Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Item item_ = model_itemGroup.QueryItem(dataItem.id); ItemData item = new ItemData(); item.id = dataItem.id; item.num = item_.num; item.iconName = UICommon.UNIT_SMALL_ICON_PATH + dataItem.id; item.iconBgName = UICommon.UNIT_ICON_BG + dataItem.quality; switch ((int)dataItem.quality) { case 0: item.nameColor = UICommon.UNIT_NAME_COLOR_0; break; case 1: item.nameColor = UICommon.UNIT_NAME_COLOR_1; break; case 2: item.nameColor = UICommon.UNIT_NAME_COLOR_2; break; case 3: item.nameColor = UICommon.UNIT_NAME_COLOR_3; break; case 4: item.nameColor = UICommon.UNIT_NAME_COLOR_4; break; case 5: item.nameColor = UICommon.UNIT_NAME_COLOR_5; break; default: item.nameColor = UICommon.UNIT_NAME_COLOR_0; break; } item.itemData = dataItem; item.type = dataItem.category; return(item); } return(null); }
void UpdateUI() { if (_itemData != null) { Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Item item = model_itemGroup.QueryItem(_itemData.id); _value_Label.text = item.num.ToString(); _itemName.color = _itemData.nameColor; _itemName.text = _itemData.itemData.name; _describe_Label.text = _itemData.itemData.desc; _itemiconbg.spriteName = _itemData.iconBgName; _itemicon.SetItemTexture(_itemData.id); ITEMCOUNT = (float)item.num; _currentItemCount = Mathf.RoundToInt(_TankItem_Slider.value * ITEMCOUNT); if (_TankItem_Slider != null && _AddTankNumLabel != null) { _AddTankNumLabel.text = _currentItemCount.ToString(); } } }
void UpdateUI() { if (_itemData != null) { Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Item item = model_itemGroup.QueryItem(_itemData.id); _value_Label.text = item.num.ToString(); _itemName.color = _itemData.nameColor; _itemName.text = _itemData.itemData.name; _describe_Label.text = _itemData.itemData.desc; _itemiconbg.spriteName = _itemData.iconBgName; _itemicon.SetItemTexture(_itemData.id); if (_itemData.type == DataConfig.ITEM_CATEGORY.CONSUME) { _use_Btn.gameObject.SetActive(true); _batchUse_Btn.gameObject.SetActive(true); } else { _use_Btn.gameObject.SetActive(false); _batchUse_Btn.gameObject.SetActive(false); } } }
public UnitData InitUnitData(DataUnit dataUnit) { if (dataUnit != null) { unlockUnits = InstancePlayer.instance.model_User.unlockUnitsId; model_units = InstancePlayer.instance.model_User.unlockUnits; model_Formation = InstancePlayer.instance.model_User.model_Formation; model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; UnitData unit = new UnitData(); unit.id = dataUnit.id; unit.quality = dataUnit.quality; unit.unitData = dataUnit; if (unlockUnits.Contains(dataUnit.id)) { unit.isUnLock = true; } else { unit.isUnLock = false; } unit.iconName = UICommon.UNIT_SMALL_ICON_PATH + dataUnit.id; unit.iconBgName = UICommon.UNIT_ICON_BG + dataUnit.quality; switch ((int)dataUnit.quality) { case 0: unit.nameColor = UICommon.UNIT_NAME_COLOR_0; break; case 1: unit.nameColor = UICommon.UNIT_NAME_COLOR_1; break; case 2: unit.nameColor = UICommon.UNIT_NAME_COLOR_2; break; case 3: unit.nameColor = UICommon.UNIT_NAME_COLOR_3; break; case 4: unit.nameColor = UICommon.UNIT_NAME_COLOR_4; break; case 5: unit.nameColor = UICommon.UNIT_NAME_COLOR_5; break; default: unit.nameColor = UICommon.UNIT_NAME_COLOR_0; break; } Model_Unit model_unit; model_units.TryGetValue(dataUnit.id, out model_unit); if (model_unit != null && model_unit.onProduce > 0) { unit.isProduct = true; } else { unit.isProduct = false; } unit.isFormation = model_Formation.IsUnitOnDuty(dataUnit.id); unit.unitType = dataUnit.bulletType; //isCanUnlock 是否能解锁 Item item = model_itemGroup.QueryItem(dataUnit.chipId); if (item.num >= dataUnit.chipCount) { unit.isCanUnlock = true; } else { unit.isCanUnlock = false; } return(unit); } return(null); }
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 + ""; } } }
public HeroData InitHeroData(DataHero data) { if (data != null) { DataHeroLeadership heroLeadershipData = heroGroupData.GetHeroLeadership(data.id); Model_HeroGroup model_heroGroup = InstancePlayer.instance.model_User.model_heroGroup; Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Model_Formation model_formation = InstancePlayer.instance.model_User.model_Formation; HeroData heroData = new HeroData(); heroData.id = data.id; heroData.heroType = (HeroType)data.type; heroData.quality = heroLeadershipData.quality; heroData.IconName = UICommon.HERO_TEXTURE_ICON_PATH + data.id; heroData.skillId = (int)heroLeadershipData.skill; heroData.data = data; DataHeroUpgrade heroUpgradeData = heroGroupData.GetHeroUpgrade(data.id, 1); heroData.heroUpgradeData = heroUpgradeData; if (model_heroGroup.heroesMap.ContainsKey(data.id)) { heroData.level = model_heroGroup.GetCurrentLevel(data.id); heroData.recruitType = RecruitType.ALREADYRECRUIT; heroData.rank = model_heroGroup.GetCurrentStage(data.id); heroData.rankName = UICommon.HERO_RANK_ICON_PATH + model_heroGroup.GetCurrentStage(data.id); heroData.exp = model_heroGroup.GetHero(data.id).exp; } else { heroData.level = 1; heroData.rank = 1; //默认军衔为下士 heroData.rankName = UICommon.HERO_RANK_ICON_PATH + "1"; heroData.exp = 0; //isCanUnlock 是否能解锁 Item item = model_itemGroup.QueryItem(heroUpgradeData.itemId); if (item.num >= heroUpgradeData.itemCount) { heroData.recruitType = RecruitType.CANRECRUIT; } else { heroData.recruitType = RecruitType.UNABLERECRUIT; } } //英雄是否上阵 for (int i = 1; i < 4; i++) { heroData.team = (TEAM)0; if (model_formation.IsTeamContaninHero(i, data.id)) { heroData.team = (TEAM)i; break; } } switch ((int)heroLeadershipData.quality) { case 1: heroData.nameColor = UICommon.UNIT_NAME_COLOR_0; heroData.IconBgName = UICommon.UNIT_ICON_BG + "0"; break; case 2: heroData.nameColor = UICommon.UNIT_NAME_COLOR_1; heroData.IconBgName = UICommon.UNIT_ICON_BG + "1"; break; case 3: heroData.nameColor = UICommon.UNIT_NAME_COLOR_2; heroData.IconBgName = UICommon.UNIT_ICON_BG + "2"; break; case 4: heroData.nameColor = UICommon.UNIT_NAME_COLOR_3; heroData.IconBgName = UICommon.UNIT_ICON_BG + "3"; break; case 5: heroData.nameColor = UICommon.UNIT_NAME_COLOR_4; heroData.IconBgName = UICommon.UNIT_ICON_BG + "4"; break; default: heroData.nameColor = UICommon.UNIT_NAME_COLOR_0; heroData.IconBgName = UICommon.UNIT_ICON_BG + "0"; break; } return(heroData); } return(null); }