require("Base/BasePanel") BagResolveAnCompoundPanel = Inherit(BasePanel) local this=BagResolveAnCompoundPanel --分解 local openLayoutType=1--1 layout1 2 layout3 分解 还是 合成 local itemResolveType=1--分解物品类型 1 道具 2 装备 local itemList={} local resolveStrList={Language[10175],Language[10176],Language[10177],Language[10176],Language[10178],Language[10179],Language[10180],Language[10181]} local resolveBtnList={}--0 是全部 local resolveBooleList={false,false,false,false,false,false,false,false} local curSelectQuantityList={}--当前选择后的稀有度 选项 {0=true,1=false ...} 稀有度是依次减小的 local curResolveAllItemList={}--最终向后段发送的分解list local isShowTishi=false local endHeroNum = 0 --碎片合成 local itemData local compoundNum=0 local compoundMaxNum=0 --装备单个分解 local equipData local callBackFun local count --初始化组件(用于子类重写) function BagResolveAnCompoundPanel:InitComponent() this.spLoader = SpriteLoader.New() this.nameText=Util.GetGameObject(self.gameObject, "bg/nameText"):GetComponent("Text") this.layout1=Util.GetGameObject(self.gameObject, "bg/layout1") this.layout2=Util.GetGameObject(self.gameObject, "bg/layout2") this.layout3=Util.GetGameObject(self.gameObject, "bg/layout3") --分解道具 this.btnBack=Util.GetGameObject(self.gameObject, "bg/btnBack") this.btnesolve=Util.GetGameObject(self.gameObject, "bg/layout1/btnSure") this.btnSure=Util.GetGameObject(self.gameObject, "bg/layout2/btnSure") for i = 1, 8 do resolveBtnList[i]=Util.GetGameObject(self.gameObject, "bg/layout1/btns/btn ("..i..")") Util.GetGameObject(resolveBtnList[i], "Text"):GetComponent("Text").text=resolveStrList[i] end this.layout2Text=Util.GetGameObject(self.gameObject, "bg/layout2/Text"):GetComponent("Text") --碎片合成 this.frame=Util.GetGameObject(self.gameObject, "bg/layout3/frame"):GetComponent("Image") this.chipFrame=Util.GetGameObject(self.gameObject, "bg/layout3/chipFrame") this.propertyIma =Util.GetGameObject(self.gameObject, "bg/layout3/property") this.icon=Util.GetGameObject(self.gameObject, "bg/layout3/icon"):GetComponent("Image") this.Slider=Util.GetGameObject(self.gameObject, "bg/layout3/Slider")--:GetComponent("Slider") this.numText=Util.GetGameObject(self.gameObject, "bg/layout3/Slider/numText1"):GetComponent("Text") this.numText1=Util.GetGameObject(self.gameObject, "bg/layout3/Slider/numText"):GetComponent("Text") this.numText1.gameObject:SetActive(true) this.resolveName=Util.GetGameObject(self.gameObject, "bg/layout3/name"):GetComponent("Text") this.addBtn=Util.GetGameObject(self.gameObject, "bg/layout3/addBtn") this.jianBtn=Util.GetGameObject(self.gameObject, "bg/layout3/jianBtn") this.btnCompound=Util.GetGameObject(self.gameObject, "bg/layout3/btnCompound") this.btnCompoundText=Util.GetGameObject(self.gameObject,"bg/layout3/btnCompound/Text"):GetComponent("Text") end --绑定事件(用于子类重写) function BagResolveAnCompoundPanel:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) for i = 0, 7 do Util.AddClick(resolveBtnList[i+1], function() this.OnShowLayout1Single(resolveBtnList[i+1],i) end) end Util.AddClick(this.btnesolve, function() this.SendBackResolveRe() end) Util.AddClick(this.btnSure, function() if openLayoutType==1 then if #curResolveAllItemList>0 then local type if itemResolveType==1 then type=2 else type=1 end NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop) this.SendBackResolveReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10182]) end elseif openLayoutType==2 then UIManager.ClosePanel(UIName.RewardEquipSingleShowPopup2) if equipData then curResolveAllItemList={} local equip = {} equip.itemId = equipData.id if not count then equip.itemNum = 1 else equip.itemNum = count end table.insert(curResolveAllItemList,equip) local type=1 NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop) this.SendBackResolveReCallBack(drop) end) end end end) Util.AddSlider(this.Slider, function(go, value) this.ShowCompoundNumData(value) end) Util.AddClick(this.addBtn, function() if itemData.itemConfig.ItemType == ItemType.Box or itemData.itemConfig.ItemType == ItemType.GMzck or itemData.itemConfig.ItemType == ItemType.GMBigZck or itemData.itemConfig.ItemType == ItemType.GMzcq or itemData.itemConfig.ItemType == ItemType.GMxck or itemData.itemConfig.ItemType == ItemType.GMxjk or itemData.itemConfig.ItemType == ItemType.GMxsZcq then--宝箱 if compoundNum 0 then if compoundNum=2 then compoundNum=compoundNum-1 this.ShowCompoundNumData(compoundNum) end end) Util.AddClick(this.btnCompound, function() if itemData.itemConfig.ItemType==ItemType.HeroDebris or itemData.itemConfig.ItemType==ItemType.ZuoQiChip or itemData.itemConfig.ItemType==ItemType.likeabilityItemChip or itemData.itemConfig.ItemType==ItemType.EquipChip or itemData.itemConfig.ItemType==ItemType.CommonChip then--碎片 if compoundNum>0 then local item={} item.itemId=itemData.id item.itemNum=compoundNum*itemData.itemConfig.UsePerCount -- Log("sssssssssssssss "..item.itemId.." "..item.itemNum) NetManager.HeroComposeRequest(item,function (drop) this.SendBackCompoundReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10183]) end elseif itemData.itemConfig.ItemType==ItemType.Box or itemData.itemConfig.ItemType == ItemType.GMzck or itemData.itemConfig.ItemType == ItemType.GMBigZck or itemData.itemConfig.ItemType == ItemType.GMzcq or itemData.itemConfig.ItemType == ItemType.GMxck or itemData.itemConfig.ItemType == ItemType.GMxjk or itemData.itemConfig.ItemType == ItemType.GMxsZcq then if compoundNum>0 then local item={} local itemList = {} item.itemId=itemData.id item.itemNum=compoundNum--*itemData.itemConfig.UsePerCount table.insert(itemList,item) -- Log("sssssssssssssss "..item.itemId.." "..item.itemNum) NetManager.UseAndPriceItemRequest(0,itemList,function (drop) if itemData.id==1342 then PrivilegeManager.SetPrivilegeUsedTimes(PRIVILEGE_TYPE.GM_YI_YUAN_UP_TIME,compoundNum) end this.SendBackCompoundReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10184]) end elseif itemData.itemConfig.ItemType==ItemType.TimeIsGold then--挂机时长奖励 if compoundNum>0 then local itemList = {itemData.id, compoundNum} NetManager.UseAndPriceItemRequest(7,itemList,function (drop) this.SendBackCompoundReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10184]) end else if compoundNum >0 then UIManager.ClosePanel(UIName.RewardItemSingleShowPopup) curResolveAllItemList={} local item={} item.itemId=itemData.id item.itemNum=compoundNum table.insert(curResolveAllItemList,item) local type if itemData.itemConfig.ItemBaseType==ItemBaseType.Equip then type=2 else type=1 end NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop) this.SendBackResolveReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10185]) end end end) end --添加事件监听(用于子类重写) function BagResolveAnCompoundPanel:AddListener() end --移除事件监听(用于子类重写) function BagResolveAnCompoundPanel:RemoveListener() end --界面打开时调用(用于子类重写) function BagResolveAnCompoundPanel:OnOpen(...) local data={...} openLayoutType=data[1] if openLayoutType==1 then--批量分解 itemResolveType=data[2] itemList=data[3] this.OnShowLayout1Data() callBackFun = data[4] if itemResolveType==4 then--特殊页签 resolveBtnList[2]:SetActive(true) resolveBtnList[3]:SetActive(true) else resolveBtnList[2]:SetActive(false) resolveBtnList[3]:SetActive(false) end elseif openLayoutType==2 then-- itemResolveType=data[2] equipData=data[3] callBackFun = data[4] count = data[5] this.OnShowLayout2Data() elseif openLayoutType==3 then--碎片合成 itemData=data[2] callBackFun = data[3] Log("itemData "..itemData.id) this.OnShowLayout3Data() elseif openLayoutType==4 then--宝箱使用 LogError("222222222222") itemData=data[2] callBackFun = data[3] this.OnShowLayout3Data() end end --初始化Layout1 function this.OnShowLayout1Data() this.nameText.text=Language[10186] this.layout1:SetActive(true) this.layout2:SetActive(false) this.layout3:SetActive(false) curSelectQuantityList={} resolveBooleList={false,false,false,false,false,false,false,false} for i = 1, #resolveBooleList do Util.GetGameObject(resolveBtnList[i], "Image"):SetActive(resolveBooleList[i]) end end --设置单个 function this.OnShowLayout1Single(_btnGo,_index)--_index 0-7 -- Log("_index ".._index) if _index==0 then--选择全部 resolveBooleList[1] = not resolveBooleList[1] resolveBooleList={resolveBooleList[1],false,false,false,false,false,false,false} for i = 1, 8 do--按钮八个 Util.GetGameObject(resolveBtnList[i], "Image"):SetActive(resolveBooleList[i]) end for i = 1, 7 do--稀有度就七个 curSelectQuantityList[i]=resolveBooleList[i+1] end else--选择其他 if resolveBooleList[1]==true then resolveBooleList[1]=false curSelectQuantityList[1]=false Util.GetGameObject(resolveBtnList[1], "Image"):SetActive(resolveBooleList[1]) end resolveBooleList[_index+1]=not resolveBooleList[_index+1] curSelectQuantityList[9-(_index+1)]=resolveBooleList[_index+1] Util.GetGameObject(_btnGo, "Image"):SetActive(resolveBooleList[_index+1]) end for k,v in pairs(curSelectQuantityList) do -- Log("curSelectQuantityList k v "..k..tostring(v)) end end --初始化Layout2 function this.OnShowLayout2Data() this.layout1:SetActive(false) this.layout2:SetActive(true) this.layout3:SetActive(false) if openLayoutType==1 then--批量分解 this.nameText.text=Language[10187] this.layout2Text.text=Language[10188] elseif openLayoutType==2 then--单个装备分解 this.nameText.text=Language[11538] this.layout2Text.text=Language[10190]..GetQuantityStrByquality(ConfigManager.GetConfigData(ConfigName.ItemConfig, equipData.id).Quantity)..Language[12122] end end --初始化Layout3 function this.OnShowLayout3Data() this.layout1:SetActive(false) this.layout2:SetActive(false) this.layout3:SetActive(true) this.frame.sprite=this.spLoader:LoadSprite(itemData.frame) this.icon.sprite=this.spLoader:LoadSprite(itemData.icon) this.resolveName.text=GetLanguageStrById(itemData.itemConfig.Name) this.chipFrame:SetActive(false) this.propertyIma:SetActive(false) local gameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1) if itemData.itemConfig.ItemType==ItemType.HeroDebris or itemData.itemConfig.ItemType==ItemType.ZuoQiChip or itemData.itemConfig.ItemType==ItemType.likeabilityItemChip or itemData.itemConfig.ItemType==ItemType.EquipChip or itemData.itemConfig.ItemType==ItemType.CommonChip then--碎片 this.chipFrame:SetActive(true) this.chipFrame:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroChipQuantityImageByquality(itemData.itemConfig.Quantity)) if itemData.itemConfig.PropertyName and itemData.itemConfig.PropertyName > 0 then this.propertyIma:SetActive(true) this.propertyIma:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetJobSpriteStrByJobNum(itemData.itemConfig.PropertyName)) else this.propertyIma:SetActive(false) end this.nameText.text=Language[10192] this.btnCompoundText.text=Language[10193] local maxCompoundValue = math.floor(itemData.num/itemData.itemConfig.UsePerCount) -- if itemData.itemConfig.ItemType==ItemType.HeroDebris or itemData.itemConfig.ItemType==ItemType.likeabilityItemChip --or itemData.itemConfig.ItemType==ItemType.EquipChip --or itemData.itemConfig.ItemType==ItemType.CommonChip then -- 神将碎片 compoundMaxNum = math.min(maxCompoundValue, gameSetting.HeroCompoundLimit, gameSetting.HeroNumlimit-LengthOfTable(HeroManager.GetAllHeroDatas())) elseif itemData.itemConfig.ItemType==ItemType.ZuoQiChip or itemData.itemConfig.ItemType==ItemType.EquipChip or itemData.itemConfig.ItemType==ItemType.CommonChip then -- 坐骑碎片 compoundMaxNum = math.min(maxCompoundValue, gameSetting.HeroCompoundLimit) end elseif itemData.itemConfig.ItemType==ItemType.Box or itemData.itemConfig.ItemType == ItemType.GMzck or itemData.itemConfig.ItemType == ItemType.GMBigZck or itemData.itemConfig.ItemType == ItemType.GMzcq or itemData.itemConfig.ItemType == ItemType.GMxck or itemData.itemConfig.ItemType == ItemType.GMxjk or itemData.itemConfig.ItemType == ItemType.GMxsZcq then--宝箱 this.nameText.text=Language[10194] this.btnCompoundText.text=Language[10195] local maxCompoundValue = itemData.num-- math.floor(itemData.num/itemData.itemConfig.UsePerCount) compoundMaxNum=maxCompoundValue > gameSetting.OpenBoxLimits and gameSetting.OpenBoxLimits or maxCompoundValue elseif itemData.itemConfig.ItemType==ItemType.TimeIsGold then--挂机产出 this.nameText.text=Language[10195] this.btnCompoundText.text=Language[10195] compoundMaxNum=itemData.num -- elseif itemData.itemConfig.ItemType==ItemType.ZuoQiChip -- or itemData.itemConfig.ItemType==ItemType.EquipChip -- or itemData.itemConfig.ItemType==ItemType.CommonChip then else itemResolveType=itemData.itemConfig.ItemBaseType this.nameText.text=Language[10196] this.btnCompoundText.text=Language[10197] compoundMaxNum=itemData.num end compoundNum=1 compoundNum= compoundNum>=compoundMaxNum and compoundMaxNum or compoundNum if compoundMaxNum > 0 then this.Slider:GetComponent("Slider").value=1 this.Slider:GetComponent("Slider").minValue=1 else this.Slider:GetComponent("Slider").value=0 this.Slider:GetComponent("Slider").minValue=0 end this.Slider:GetComponent("Slider").maxValue=compoundMaxNum --this.ShowCompoundNumData(compoundNum) this.ShowCompoundNumData(compoundMaxNum) end --道具 和 装备分解 发送请求 function this.SendBackResolveRe() isShowTishi=false curResolveAllItemList={} -- Log("itemResolveType "..itemResolveType) if itemResolveType==ItemBaseType.Equip then--装备 for i = 1, #itemList do if resolveBooleList[1]==true and itemList[i].itemConfig.IfResolve==1 then if itemList[i].equipConfig.Quality>=4 then isShowTishi=true end table.insert(curResolveAllItemList,itemList[i].did) else -- Log("itemList[i].equipConfig.Quality "..itemList[i].equipConfig.Quality) if curSelectQuantityList[itemList[i].equipConfig.Quality]==true and itemList[i].itemConfig.IfResolve==1 then -- Log("itemList[i].did "..itemList[i].did) if itemList[i].equipConfig.Quality>=4 then isShowTishi=true end table.insert(curResolveAllItemList,itemList[i].did) end end end else--道具 for i = 1, #itemList do if resolveBooleList[1]==true and itemList[i].itemConfig.IfResolve==1 then if itemList[i].itemConfig.Quantity>=4 then isShowTishi=true end local item={} item.itemId=itemList[i].id item.itemNum=itemList[i].num item.endingTime=itemList[i].endingTime table.insert(curResolveAllItemList,item) else if curSelectQuantityList[itemList[i].itemConfig.Quantity]==true and itemList[i].itemConfig.IfResolve==1 then if itemList[i].itemConfig.Quantity>=4 then isShowTishi=true end local item={} item.itemId=itemList[i].id item.itemNum=itemList[i].num item.endingTime=itemList[i].endingTime table.insert(curResolveAllItemList,item) end end end end Log(#curResolveAllItemList) --for i = 1, #curResolveAllItemList do -- Log(" wwwwwwwwwwww "..curResolveAllItemList[i].itemId) --end if isShowTishi then this.OnShowLayout2Data() else if #curResolveAllItemList>0 then local type if itemResolveType==ItemBaseType.Equip then type=2 else type=1 end NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop) this.SendBackResolveReCallBack(drop) end) else PopupTipPanel.ShowTip(Language[10182]) end end end --道具 和 装备分解 发送请求后 回调 function this.SendBackResolveReCallBack(drop) this:ClosePanel() local isShowReward=false if drop.itemlist~=nil and #drop.itemlist>0 then for i = 1, #drop.itemlist do if drop.itemlist[i].itemNum>0 then isShowReward=true break end end end if isShowReward then UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function () BagManager.OnShowTipDropNumZero(drop) if callBackFun then callBackFun() end end) else BagManager.OnShowTipDropNumZero(drop) end if callBackFun then callBackFun() end end function this.SendBackCompoundReCallBack(drop) this:ClosePanel() LogError("#drop=="..#drop) UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function () --UIManager.OpenPanel(UIName.BagPanel) if callBackFun then callBackFun() end end,nil,nil,nil,true) --改为后端刷新了 --BagManager.UpdateItemsNum(itemData.id,compoundNum*itemData.itemConfig.UsePerCount) end function this.ShowCompoundNumData(value) -- Log("当前slider值 "..value) compoundNum=value this.Slider:GetComponent("Slider").value=value this.numText1.text = value if itemData.itemConfig.ItemType==ItemType.HeroDebris or itemData.itemConfig.ItemType==ItemType.ZuoQiChip or itemData.itemConfig.ItemType==ItemType.likeabilityItemChip or itemData.itemConfig.ItemType==ItemType.EquipChip or itemData.itemConfig.ItemType==ItemType.CommonChip then--碎片 this.numText.text= Language[10198]..value*itemData.itemConfig.UsePerCount..Language[10199]..value..Language[10200].. string.gsub(GetLanguageStrById(itemData.itemConfig.Name),Language[10201],"") elseif itemData.itemConfig.ItemType==ItemType.Box or itemData.itemConfig.ItemType == ItemType.GMzck or itemData.itemConfig.ItemType == ItemType.GMBigZck or itemData.itemConfig.ItemType == ItemType.GMzcq or itemData.itemConfig.ItemType == ItemType.GMxck or itemData.itemConfig.ItemType == ItemType.GMxjk or itemData.itemConfig.ItemType == ItemType.GMxsZcq then this.numText.text= Language[10202]..value..Language[10200]..GetLanguageStrById(itemData.itemConfig.Name).."。" elseif itemData.itemConfig.ItemType==ItemType.TimeIsGold then--挂机奖励 this.numText.text= Language[10202]..value..Language[10200]..GetLanguageStrById(itemData.itemConfig.Name).."。" else this.numText.text= Language[10196]..value..Language[10200]..GetLanguageStrById(itemData.itemConfig.Name).."。" end end --界面关闭时调用(用于子类重写) function BagResolveAnCompoundPanel:OnClose() if callBackFun then callBackFun() end end --界面销毁时调用(用于子类重写) function BagResolveAnCompoundPanel:OnDestroy() this.spLoader:Destroy() end return BagResolveAnCompoundPanel