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 --初始化组件(用于子类重写) function RoleEquipTreasureChangePopup:InitComponent() equipData = {} this.btnBack= Util.GetGameObject(self.transform, "btnBack") this.GameObject=Util.GetGameObject(self.transform, "GameObject") this.BasePropertyList = {} this.RefinePropertyList = {} this.TreePropertyList = {} for i = 1, 2 do this.BasePropertyList[i] = {} this.RefinePropertyList[i] = {} this.TreePropertyList[i] = {} end 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].EquipProImg = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/proImg"):GetComponent("Image") this.treasurePanel[i].EquipName = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/name/text"):GetComponent("Text") this.treasurePanel[i].EquipFrame = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/frame"):GetComponent("Image") this.treasurePanel[i].EquipIcon = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/icon"):GetComponent("Image") 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].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].EquipLvText = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/lvTxt"):GetComponent("Text") this.treasurePanel[i].EquipRefineLvTxt = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/starTxt"):GetComponent("Text") this.treasurePanel[i].EquipTreeLvTxt = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/treeImg/treeTxt"):GetComponent("Text") this.treasurePanel[i].treeImg = Util.GetGameObject(this.treasurePanel[i].bg, "equipInfo/treeImg") this.treasurePanel[i].treeImg:SetActive(false) --属性信息 this.treasurePanel[i].bgScroll = Util.GetGameObject(this.treasurePanel[i].bg, "Scroll") --基础 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) 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.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 = Util.LoadSprite(PowerChangeIconDef[1]) elseif(Power[1] < Power[2] )then this.treasurePanel[1].powerUPorDown:SetActive(true) this.treasurePanel[1].powerUPorDown:GetComponent("Image").sprite = Util.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 = Util.LoadSprite(PowerChangeIconDef[1]) elseif Power[2] < Power[1] then this.treasurePanel[2].powerUPorDown:SetActive(true) this.treasurePanel[2].powerUPorDown:GetComponent("Image").sprite = Util.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]) this.treasurePanel[i].EquipFrame.sprite = Util.LoadSprite(equipData[i].frame) this.treasurePanel[i].EquipIcon.sprite = Util.LoadSprite(equipData[i].icon) this.treasurePanel[i].EquipProImg.sprite = Util.LoadSprite(equipData[i].proIcon) --强化等级 local lv = equipData[i].lv if lv == 0 then this.treasurePanel[i].EquipLvText.gameObject:SetActive(false) else this.treasurePanel[i].EquipLvText.gameObject:SetActive(true) this.treasurePanel[i].EquipLvText.text = lv end --精良等级 local refine=equipData[i].refineLv if refine == 0 then this.treasurePanel[i].EquipRefineLvTxt.gameObject:SetActive(false) else this.treasurePanel[i].EquipRefineLvTxt.gameObject:SetActive(true) this.treasurePanel[i].EquipRefineLvTxt.text="+"..refine end --神应等级 -- local treeLv = equipData[i].treeLv -- if equipData[i].upHeroDid == "" or equipData[i].upHeroDid == "0" or treeLv == 0 then -- this.treasurePanel[i].treeImg:SetActive(false) -- else -- this.treasurePanel[i].treeImg:SetActive(true) -- this.treasurePanel[i].EquipTreeLvTxt.text = treeLv -- end --(基础属性) 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 --(神应属性) -- local treeInfo=EquipTreasureManager.GetCurLvPropertyValue(3,equipData[i].treePool,equipData[i].treeLv) -- 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 treeLv == 0 then -- this.treasurePanel[i].TreeAttri:SetActive(false) -- else -- this.treasurePanel[i].TreeAttri:SetActive(true) -- this.treasurePanel[i].bgScroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,500) -- this.SetPropertyShow2(treeInfo,this.TreePropertyList[i],this.treasurePanel[i].TreeAttriGrid) -- 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 end --神应专用 function this.SetPropertyShow2(_infos,_preList,_grid) local curTree = SacredTreeManager.CulAttri() local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0).PropertyUnlcokLevelForClient local dataCount=LengthOfTable(_infos) local preCount=#_preList for i = 1, dataCount-preCount do local go = newObject(this.TextPre) local t = math.floor((i+1)/2) local trans = Util.GetGameObject(_grid.transform,"line ("..t..")") go.transform:SetParent(trans.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(attriConfig) do local obj=_preList[index] local proper=propertyConfig[value[1]] local string 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 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, #_preList do if i>=index 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 end return RoleEquipTreasureChangePopup