require("Base/BasePanel") RoleEquipTreasureChangePopup = Inherit(BasePanel) local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local spcialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig) local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local this=RoleEquipTreasureChangePopup local type--1 穿装备 2 卸装备 3 替换装备 local curHeroData local equipData local openThisPanel local equipIdList local equipDataList local position local isGongMing = false local isShowBtn --初始化组件(用于子类重写) function RoleEquipTreasureChangePopup:InitComponent() equipData = {} this.spLoader = SpriteLoader.New() this.btnBack= Util.GetGameObject(self.transform, "btnBack") this.GameObject=Util.GetGameObject(self.transform, "GameObject") this.BasePropertyList = {} this.RefinePropertyList = {} this.TreePropertyList = {} this.TreePropertyList2 = {} this.strongPropertyList = {} this.RefineMonsterPropertyList = {} for i = 1, 2 do this.BasePropertyList[i] = {} this.RefinePropertyList[i] = {} this.TreePropertyList[i] = {} this.TreePropertyList2[i] = {} this.strongPropertyList[i] = {} this.RefineMonsterPropertyList[i] = {} end this.preList = {} this.treasurePanel = {} for i = 1, 2 do if not this.treasurePanel[i] then this.treasurePanel[i] = {} --信息 this.treasurePanel[i].bg = Util.GetGameObject(self.transform, "GameObject/bg"..i) this.treasurePanel[i].desc = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/Text"):GetComponent("Text") this.treasurePanel[i].EquipName = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/name/text"):GetComponent("Text") this.treasurePanel[i].EquipTypeText = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/equipTypeText"):GetComponent("Text") this.treasurePanel[i].powerUPorDown = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/powerUPorDown") this.treasurePanel[i].qualityText = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/qualityText"):GetComponent("Text") this.treasurePanel[i].powerNum = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/powerNum"):GetComponent("Text") this.treasurePanel[i].pos = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/pos") --按钮 this.treasurePanel[i].EquipBtns = Util.GetGameObject(self.transform, "GameObject/bg"..i.."/btns") this.treasurePanel[i].EquipBtnStrong = Util.GetGameObject(this.treasurePanel[i].EquipBtns, "btnStrong") this.treasurePanel[i].EquipBtnRefine = Util.GetGameObject(this.treasurePanel[i].EquipBtns, "btnRefine") this.treasurePanel[i].EquipBtnRemove = Util.GetGameObject(this.treasurePanel[i].EquipBtns, "btnRemove") this.treasurePanel[i].EquipBtnAdd = Util.GetGameObject(this.treasurePanel[i].EquipBtns, "btnAdd") this.treasurePanel[i].EquipBtnChange = Util.GetGameObject(this.treasurePanel[i].EquipBtns, "btnChange") --红点 this.treasurePanel[i].StrongRed = Util.GetGameObject(this.treasurePanel[i].EquipBtnStrong, "red") this.treasurePanel[i].RefineRed = Util.GetGameObject(this.treasurePanel[i].EquipBtnRefine, "red") --属性信息 this.treasurePanel[i].bgScroll = Util.GetGameObject(this.treasurePanel[i].bg, "Scroll") this.treasurePanel[i].bgScrollContent = Util.GetGameObject(this.treasurePanel[i].bg, "Scroll/grid") --基础 this.treasurePanel[i].BaseAttri = Util.GetGameObject(this.treasurePanel[i].bg, "Scroll/grid/baseAttri") this.treasurePanel[i].BaseAttriNum = Util.GetGameObject(this.treasurePanel[i].BaseAttri, "name/attriNum"):GetComponent("Text") this.treasurePanel[i].BaseAttriGrid = Util.GetGameObject(this.treasurePanel[i].BaseAttri, "grid") --精炼 this.treasurePanel[i].RefineAttri = Util.GetGameObject(this.treasurePanel[i].bgScroll, "grid/refineAttri") this.treasurePanel[i].RefineAttriNum = Util.GetGameObject(this.treasurePanel[i].RefineAttri, "name/attriNum"):GetComponent("Text") this.treasurePanel[i].RefineAttriGrid = Util.GetGameObject(this.treasurePanel[i].RefineAttri, "grid") --神应 this.treasurePanel[i].TreeAttri = Util.GetGameObject(this.treasurePanel[i].bgScroll, "grid/treeAttri") this.treasurePanel[i].TreeAttriNum = Util.GetGameObject(this.treasurePanel[i].TreeAttri, "name/attriNum"):GetComponent("Text") this.treasurePanel[i].TreeAttriGrid = Util.GetGameObject(this.treasurePanel[i].TreeAttri, "grid") this.treasurePanel[i].TreeAttri:SetActive(false) --强化共鸣 this.treasurePanel[i].strongAttri = Util.GetGameObject(this.treasurePanel[i].bgScroll, "grid/strongAttri") this.treasurePanel[i].strongAttriNum = Util.GetGameObject(this.treasurePanel[i].strongAttri, "name/attriName"):GetComponent("Text") this.treasurePanel[i].strongAttriGrid = Util.GetGameObject(this.treasurePanel[i].strongAttri, "grid") this.treasurePanel[i].strongAttri:SetActive(false) --精炼共鸣 this.treasurePanel[i].refineMasterAttri = Util.GetGameObject(this.treasurePanel[i].bgScroll, "grid/refineMasterAttri") this.treasurePanel[i].refineMasterAttriNum = Util.GetGameObject(this.treasurePanel[i].refineMasterAttri, "name/attriName"):GetComponent("Text") this.treasurePanel[i].refineMasterAttriGrid = Util.GetGameObject(this.treasurePanel[i].refineMasterAttri, "grid") this.treasurePanel[i].refineMasterAttri:SetActive(false) end end --其他 this.propertyPre=Util.GetGameObject(self.transform, "GameObject/bg1/PropertyTxt") this.curEquipSign=Util.GetGameObject(self.transform, "GameObject/bg1/Text") this.TextPre = Util.GetGameObject(self.transform, "GameObject/bg1/TextPre") this.line = Util.GetGameObject(self.transform, "GameObject/bg1/line") this.space = Util.GetGameObject(self.transform, "GameObject/bg1/space") end --绑定事件(用于子类重写) function RoleEquipTreasureChangePopup:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) Util.AddClick(this.treasurePanel[1].EquipBtnRemove, function() equipIdList={} equipDataList={} table.insert(equipIdList,equipData[1].idDyn) table.insert(equipDataList,equipData[1]) NetManager.EquipUnLoadOptRequest(curHeroData.dynamicId,equipIdList ,2,function () self:ClosePanel() openThisPanel.UpdateEquipPosHeroData(2,type,equipDataList) end) end) Util.AddClick(this.treasurePanel[1].EquipBtnAdd, function() local config=spcialConfig[40] if config then local limits = string.split(config.Value, "|") if limits then local heroConfig=ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroData.id) local lvs=string.split(limits[1],"#") local stars=string.split(limits[2],"#") local lv=tonumber(lvs[2]) if PlayerManager.level Power[2]) then this.treasurePanel[1].powerUPorDown:SetActive(true) this.treasurePanel[1].powerUPorDown:GetComponent("Image").sprite = this.spLoader:LoadSprite(PowerChangeIconDef[1]) elseif(Power[1] < Power[2] )then this.treasurePanel[1].powerUPorDown:SetActive(true) this.treasurePanel[1].powerUPorDown:GetComponent("Image").sprite = this.spLoader:LoadSprite(PowerChangeIconDef[2]) else this.treasurePanel[1].powerUPorDown:SetActive(false) end elseif type==3 and equipData[1] ~= nil and i == 2 then if Power[2] > Power[1] then this.treasurePanel[2].powerUPorDown:SetActive(true) this.treasurePanel[2].powerUPorDown:GetComponent("Image").sprite = this.spLoader:LoadSprite(PowerChangeIconDef[1]) elseif Power[2] < Power[1] then this.treasurePanel[2].powerUPorDown:SetActive(true) this.treasurePanel[2].powerUPorDown:GetComponent("Image").sprite = this.spLoader:LoadSprite(PowerChangeIconDef[2]) else this.treasurePanel[2].powerUPorDown:SetActive(false) end else this.treasurePanel[1].powerUPorDown:SetActive(false) end this.treasurePanel[i].qualityText.text = GetStringByEquipQua(equipConfigData.Level,GetQuaStringByEquipQua(equipConfigData.Level)) this.treasurePanel[i].EquipName.text=GetStringByEquipQua(itemConfigData.Quantity,GetLanguageStrById(itemConfigData.Name)) this.treasurePanel[i].EquipTypeText.text = string.format(Language[11803],EquipTreasureTypeStr[equipConfigData.Location]) if not this.preList[i] then this.preList[i] = SubUIManager.Open(SubUIConfig.ItemView,this.treasurePanel[i].pos.transform) end this.preList[i].gameObject:SetActive(true) this.preList[i]:OnOpen(false,{equipConfigData.Id,0},1,false, false,false, 0,equipData[i].idDyn) --(基础属性) this.treasurePanel[i].bgScroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,100) local baseInfo = EquipTreasureManager.GetCurLvPropertyValue(1,equipData[i].levelPool,equipData[i].lv) this.treasurePanel[i].BaseAttriNum.text = string.format("[强化等级:%s/%s]",equipData[i].lv,equipData[i].maxLv) this.SetPropertyShow1(baseInfo,this.BasePropertyList[i],this.treasurePanel[i].BaseAttriGrid) --(精炼属性) local refineInfo = EquipTreasureManager.GetCurLvPropertyValue(2,equipData[i].refinePool,equipData[i].refineLv,true) this.treasurePanel[i].RefineAttriNum.text = string.format("[精炼等级:%s/%s]",equipData[i].refineLv,equipData[i].maxRefineLv) if LengthOfTable(refineInfo) == 0 or refineInfo == nil then this.treasurePanel[i].RefineAttri:SetActive(false) else this.treasurePanel[i].RefineAttri:SetActive(true) this.treasurePanel[i].bgScroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,250) this.SetPropertyShow1(refineInfo,this.RefinePropertyList[i],this.treasurePanel[i].RefineAttriGrid) end if equipData[i].upHeroDid == "" or equipData[i].upHeroDid == "0" then this.treasurePanel[i].strongAttri.gameObject:SetActive(false) this.treasurePanel[i].refineMasterAttri:SetActive(false) else --强化共鸣 local _QH = this.GongMingSetData(1,this.strongPropertyList[i],this.treasurePanel[i].strongAttriGrid,this.treasurePanel[i].strongAttriNum,this.treasurePanel[i].strongAttri) --精炼共鸣 local _JL = this.GongMingSetData(2,this.RefineMonsterPropertyList[i],this.treasurePanel[i].refineMasterAttriGrid,this.treasurePanel[i].refineMasterAttriNum,this.treasurePanel[i].refineMasterAttri) -- 判断显示界面高度 local height = 250 height = _QH and height + 110 or height height = _JL and height + 110 or height this.treasurePanel[i].bgScroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,height) end --(神应属性) local treeInfo=SacredTreeManager.GetCurLvPropertyValue(3,equipData[i].treePool,equipData[i].treeLv or 0) this.treasurePanel[i].TreeAttriNum.text = string.format("[神应等级:%s/%s]",equipData[i].treeLv,equipData[i].maxTreeLv) --if equipData[i].upHeroDid == "" or equipData[i].upHeroDid == "0" or (equipData[i].treeLv < 1 and SacredTreeManager.CulAttri(equipData[1]) < 1) then if (equipData[i].treeLv < 1 and SacredTreeManager.CulAttri(equipData[1]) < 1) then this.treasurePanel[i].TreeAttri:SetActive(false) else this.treasurePanel[i].TreeAttri:SetActive(true) this.treasurePanel[i].bgScroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,589) this.SetPropertyShow2(treeInfo,this.TreePropertyList[i],this.treasurePanel[i].TreeAttriGrid,this.TreePropertyList2[i]) end if i == 1 then this.treasurePanel[i].StrongRed:SetActive(HeroManager.CheckIsUpTreasure(equipData[i].idDyn,1)) this.treasurePanel[i].RefineRed:SetActive(HeroManager.CheckIsUpTreasure(equipData[i].idDyn,2)) end -- 内容置顶 this.treasurePanel[i].bgScrollContent.transform.localPosition = Vector2.New(0, 0) end function this.GongMingSetData(curTabIndex,proPreList,grid,title,go) --获取穿戴宝物强化/精炼的最小等级 local minLv--最小等级 local maxlv --最大等级 if #curHeroData.jewels < 2 then go.gameObject:SetActive(false) return end go.gameObject:SetActive(true) for i = 1, #curHeroData.jewels do local curEquipTreasureData = EquipTreasureManager.GetTreasureData(curHeroData.jewels[i]) if curTabIndex == 1 then if minLv then if curEquipTreasureData.lv < minLv then minLv = curEquipTreasureData.lv end else minLv = curEquipTreasureData.lv end if maxlv then if curEquipTreasureData.maxLv < maxlv then maxlv = curEquipTreasureData.maxLv end else maxlv = curEquipTreasureData.maxLv end elseif curTabIndex == 2 then if minLv then if curEquipTreasureData.refineLv < minLv then minLv = curEquipTreasureData.refineLv end else minLv = curEquipTreasureData.refineLv end if maxlv then if curEquipTreasureData.maxRefineLv < maxlv then maxlv = curEquipTreasureData.maxRefineLv end else maxlv = curEquipTreasureData.maxRefineLv end end end local curJewelResonanceConfig = nil local allCurTypeJewelResonanceConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.JewelResonanceConfig,"Type",curTabIndex) table.sort(allCurTypeJewelResonanceConfig,function(a,b) return a.SortId强化大师%s级",curJewelResonanceConfig.SortId) else title.text = string.format("精炼大师%s级",curJewelResonanceConfig.SortId) end for i = 1, math.max(#curJewelResonanceConfig.Property,#proPreList) do if not curJewelResonanceConfig.Property[i] then proPreList[i].gameObject:SetActive(false) else if not proPreList[i] then proPreList[i] = newObjToParent(this.TextPre,grid.transform) end proPreList[i].gameObject:SetActive(true) local str = GetLanguageStrById(propertyConfig[curJewelResonanceConfig.Property[i][1]].Info).."+"..GetPropertyFormatStr(propertyConfig[curJewelResonanceConfig.Property[i][1]].Style,curJewelResonanceConfig.Property[i][2]) proPreList[i].transform:GetComponent("Text").text = string.format("%s",str) end end return true end --神应专用 function this.SetPropertyShow2(_infos,_preList,_grid,_preList2) local curTree = SacredTreeManager.CulAttri(equipData[1]) local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0).PropertyUnlcokLevelForClient local dataCount=LengthOfTable(_infos) local preCount=#_preList ---行数 for i = 1, math.ceil(dataCount/2) - preCount do local go = newObject(this.line) go.transform:SetParent(_grid.transform) go.transform.localScale = Vector3.one go.transform.localPosition = Vector3.zero go.gameObject:SetActive(false) table.insert(_preList,go) end preCount = #_preList2 for i = 1, dataCount - preCount do local go = newObject(this.TextPre) table.insert(_preList2,go) go.transform:SetParent(_preList[math.ceil(#_preList2/2)].transform) go.transform.localScale = Vector3.one go.transform.localPosition = Vector3.zero go.gameObject:SetActive(false) end local index=1 for key, value in pairs(attriConfig) do local obj = _preList2[index] _preList[math.ceil(index/2)].gameObject:SetActive(true) local proper=propertyConfig[value[1]] local string = "" if _infos[value[1]] then if proper.Style==1 then string = GetLanguageStrById(proper.Info).."+".._infos[value[1]].currValue--value.currValue else string = GetLanguageStrById(proper.Info).."+".._infos[value[1]].currValue/100 .."%" end end if index <= curTree then string = ""..string.."" else -- string = ""..string.."\n".."(四灵试炼"..attriConfig[index][2].."层解锁)" string = ""..string.."\n"..""..string.format("(四灵试炼%s层解锁)",attriConfig[index][2]).."" end obj.transform:GetComponent("Text").text = string obj.gameObject:SetActive(true) index=index+1 end for i = 1, #_preList2 do if i >= index then _preList2[i]:SetActive(false) end end for i = 1, #_preList do if i > math.ceil(index/2) then _preList[i]:SetActive(false) end end end function this.SetPropertyShow1(_infos,_preList,_grid) local dataCount=LengthOfTable(_infos) local preCount=#_preList for i = 1, dataCount-preCount do local go = newObject(this.TextPre) go.transform:SetParent(_grid.transform) go.transform.localScale = Vector3.one go.transform.localPosition = Vector3.zero go.gameObject:SetActive(false) table.insert(_preList,go) end local index=1 for key, value in pairs(_infos) do local obj=_preList[index] local proper=propertyConfig[key] if proper.Style==1 then obj.transform:GetComponent("Text").text = GetLanguageStrById(proper.Info).."+".. value.currValue else obj.transform:GetComponent("Text").text=GetLanguageStrById(proper.Info).."+"..value.currValue/100 .."%" end obj.gameObject:SetActive(true) index=index+1 end for i = 1, #_preList do if i>=index then _preList[i]:SetActive(false) end end end --界面关闭时调用(用于子类重写) function RoleEquipTreasureChangePopup:OnClose() end --界面销毁时调用(用于子类重写) function RoleEquipTreasureChangePopup:OnDestroy() type=0--1 穿装备 2 卸装备 3 替换装备 curHeroData=nil equipData=nil openThisPanel=nil equipIdList=nil equipDataList=nil position=0 this.spLoader:Destroy() for k,v in pairs(this.preList) do SubUIManager.Close(v) end this.preList = {} end return RoleEquipTreasureChangePopup