local UIEquipmentCommon = require "View/Equipment/UIEquipmentCommon" local UIEquipmentStrengthen = UIViewClass(UIEquipmentCommon) local resonance_info = require 'Proto/resonance_info_pb' function UIEquipmentStrengthen:OnCreated() self.attrComps = {} for i = 1, #self.group_Attr do self.attrComps[i] = { [1] = self.group_Attr[i].icon_attr, [2] = self.group_Attr[i].lab_attr, [3] = self.group_Attr[i].txt_attr, } end end function UIEquipmentStrengthen:OnOpened(context) self:RegistSystemEvent(EventID.UI_EquipEnhance_Success, self.OnEquipEnhanceSuccess) end function UIEquipmentStrengthen:OnEquipEnhanceSuccess() self:UpdateEquipEnhanceInfo() end function UIEquipmentStrengthen:RefreshEquipInfo(equipInfo) if self.equipInfo ~= equipInfo then self.equipInfo = equipInfo self:UpdateEquipEnhanceInfo() end end function UIEquipmentStrengthen:UpdateEquipEnhanceInfo() local curStrengthenData = MDL.Equipment.GetEquipStrengthenData(self.equipInfo.ID) if curStrengthenData then local nextConfig = DataSheetManager.EquipEnhance:GetDataByID_EnhanceLevel(curStrengthenData.ID, curStrengthenData.EnhanceLevel + 1) if nextConfig then self.txt_LVBefore.text = UTL.Item.SetNobilityIcon(curStrengthenData.EnhanceLevel, self.icon_Rank1) -- 爵位转换 self.txt_LVAfter.text = UTL.Item.SetNobilityIcon(nextConfig.EnhanceLevel, self.icon_Rank2) -- 爵位转换 self:SetCostItem(nextConfig.Item_Table) self.obj_full:SetState(0) for i = 1, #curStrengthenData.Attr_Table do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,true) self.attrComps[i][3] = self.group_Attr[i].txt_attr UTL.Attr.SetAttrItem(self.attrComps[i],curStrengthenData.Attr_Table[i].AttrType,curStrengthenData.Attr_Table[i].AttrNum,true) self.group_Attr[i].txt_attrAdd.text = nextConfig.Attr_Table[i].AttrNum - curStrengthenData.Attr_Table[i].AttrNum end for i = #curStrengthenData.Attr_Table + 1, #self.group_Attr do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,false) end else --已满级 self.txt_LVLimit.text = UTL.Item.SetNobilityIcon(curStrengthenData.EnhanceLevel, self.icon_RankFull) self.obj_full:SetState(1) for i = 1, #curStrengthenData.Attr_Table do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,true) self.attrComps[i][3] = self.group_Attr[i].txt_max UTL.Attr.SetAttrItem(self.attrComps[i],curStrengthenData.Attr_Table[i].AttrType,curStrengthenData.Attr_Table[i].AttrNum,true) self.group_Attr[i].txt_attrAdd.text = curStrengthenData.Attr_Table[i].AttrNum end for i = #curStrengthenData.Attr_Table + 1, #self.group_Attr do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,false) end end else UIUtils.SetActive(self.icon_Rank1, false) UIUtils.SetActive(self.icon_Rank2, false) local strengthenData = DataSheetManager.EquipEnhance:GetDataByID_EnhanceLevel(self.equipInfo.EquipData.EquipType, 1) for i = 1, #strengthenData.Attr_Table do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,true) self.attrComps[i][3] = self.group_Attr[i].txt_attr UTL.Attr.SetAttrItem(self.attrComps[i],strengthenData.Attr_Table[i].AttrType,0,true) self.group_Attr[i].txt_attrAdd.text = strengthenData.Attr_Table[i].AttrNum end for i = #strengthenData.Attr_Table + 1, #self.group_Attr do UIUtils.SetActive(self.group_Attr[i].obj_group.gameObject,false) end self.txt_LVBefore.text = 0 self.txt_LVAfter.text = 1 self:SetCostItem(strengthenData.Item_Table) self.obj_full:SetState(0) end local isRed = CTL.Equipment.CheckEquipIfStrength(self.equipInfo) self.btn_Strengthen:SetRedPoint(isRed) --一键强化红点应该是该角色下的所有装备 if isRed then self.btn_QuickStrengthen:SetRedPoint(true) else local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) local roleStrengthRed = CTL.Equipment.CheckEquipIfStrengthByHeroID(heroId) self.btn_QuickStrengthen:SetRedPoint(roleStrengthRed) end end function UIEquipmentStrengthen:SetResonanceLvType() self.resonanceLvType = resonance_info.Equip_Enhance end function UIEquipmentStrengthen:SetCostItem(itemTable) for i, v in ipairs(self.group_Cost) do local itemData = itemTable[i] if itemData then UIUtils.SetActive(v.gameObject, true) local itemId = itemData.ItemID local itemNum = itemData.ItemNum if MDL.Currency.IsMoneyTypeByItemID(itemId) then local count = MDL.Currency.GetMoneyCount(itemId) count = count >= itemNum and itemNum or UTL.Color.FormatRedColor(itemNum) UTL.Item.MoneyIcon(v.icon_Cost, itemId) v.txt_Cost.text = count else local count = MDL.Bag.GetItemCount(itemId) or 0 if count >= itemNum then count = count .."/".. itemNum else count = UTL.Color.FormatRedColor(count) .."/".. itemNum end UTL.Item.ItemIconWithoutBg(v.icon_Cost, itemId) v.txt_Cost.text = count end else UIUtils.SetActive(v.gameObject, false) end end end function UIEquipmentStrengthen:OnButtonClicked(comp) if comp == self.btn_QuickStrengthen then local heroId = MDL.Equipment.GetEquipHeroId(self.equipInfo.ID) local equipInfos = MDL.Equipment.GetEquipmentsByHeroId(heroId) CTL.Equipment.OpenEquipQuickStrengthen(equipInfos) elseif comp == self.btn_Strengthen then CTL.Equipment.StrengthenEquip(self.equipInfo) elseif comp == self.btn_Resonance then self:OnResonanceLvClick() end end return UIEquipmentStrengthen