----- 魂印合成 ----- local this = {} local soulPrintDatas = {}--所有可合成数据 local materidaIsCan = false--合成是材料是否满足 local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local equipSign = ConfigManager.GetConfig(ConfigName.EquipConfig) local curSelectSoulPrint = {}--当前选择的合成魂印 local curSelectGO--当前选择的合成列表中对象 local needSoulPrint = {}--三个魂印消耗材料对象 local materialState = {}--材料数据 local openThisPanel local needGold = {} local allGo = {} local selectUpList={} local itemType=0 function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() allGo = {} for i = 1, 3 do selectUpList[i]=0 needSoulPrint[i] = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/titleGo/needEquip"..i) end this.compoundSoulPrint = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/titleGo/compoundEquip") this.compoundSoulPrintBtn = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/titleGo/compoundEquip/frame") for i = 1, 2 do needGold[i] = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/compoundBtn/GameObject/needGoldText ("..i..")") end --this.needGoldText = Util.GetGameObject(gameObject, "CompoundPanel_SoulPrint/compoundBtn/needGoldText"):GetComponent("Text") this.compoundBtn = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/compoundBtn") this.autoSelectBtn = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/autoCompoundBtn") this.equipPre = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/equipPre") this.ScrollBar=Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/Scrollbar"):GetComponent("Scrollbar") local v2 = Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/scroll"):GetComponent("RectTransform").rect this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "CompoundPanel_PlayerGift/scroll").transform, this.equipPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(40,20)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 end function this:BindEvent() Util.AddClick(this.compoundBtn, function() this.Compound() end) -- Util.AddClick(this.autoSelectBtn, function() this.AutoSelectSoulPrint() end) for i = 1, 3 do Util.AddClick(needSoulPrint[i], function() --materialState[index] = {state = true,equipSignConFig = equipSign} UIManager.OpenPanel(UIName.SelectGiftListPopup,openThisPanel,selectUpList,i,curSelectSoulPrint,itemType) end) Util.AddLongPressClick(needSoulPrint[i], function() if selectUpList[i]~=0 then UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2,this,{id=selectUpList[i].id,num=0},0,false,nil,nil,4) end end, 0.5) end Util.AddClick(this.compoundSoulPrintBtn, function() --UIManager.OpenPanel(UIName.SoulPrintPopUp,0,nil,curSelectSoulPrint.Id,nil,nil) UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2,this,{id=curSelectSoulPrint.Id,num=0},0,false,nil,nil,4) end) end function this:AddListener() end function this:RemoveListener() end local sortingOrder = 0 function this:OnSortingOrderChange(_sortingOrder) sortingOrder = _sortingOrder for i, v in pairs(allGo) do Util.AddParticleSortLayer(v, _sortingOrder - sortingOrder ) end end function this:OnShow(_openThisPanel) curSelectSoulPrint = {} this.OnShowData() this.StartCompoundSoulPrint(curSelectSoulPrint, true) openThisPanel = this itemType=ItemBaseType.PlayerGift end function this.OnShowData() soulPrintDatas = {} --local allDatas = ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.EquipConfig,"Position",5,"Quality",7) for i,v in ConfigPairs(equipSign) do if v.Position==7 and v.Formula and #v.Formula>0 and tonumber(v.Formula[1][1])~=nil then table.insert(soulPrintDatas,v) end end table.sort(soulPrintDatas,function(a,b) if a.Quality==b.Quality then return a.Id < b.Id else return a.Quality < b.Quality end end) curSelectSoulPrint = soulPrintDatas[1] this.ScrollView:SetData(soulPrintDatas, function (index, go) this.SingleItemDataShow(go, soulPrintDatas[index]) end) end function this.ShowGoldNum(equipSign) for i = 1, #needGold do needGold[i]:SetActive(false) end for i = 1, #equipSign.Resource do if needGold[i] then needGold[i]:SetActive(true) Util.GetGameObject(needGold[i],"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(ConfigManager.GetConfigData(ConfigName.ItemConfig,equipSign.Resource[i][1]).ResourceID)) if equipSign.Resource[1][2] > BagManager.GetItemCountById(equipSign.Resource[1][1]) then materidaIsCan = false needGold[i]:GetComponent("Text").text = PrintWanNum2(equipSign.Resource[i][2])--string.format("%s", equipSign.Resource[i][2]) else materidaIsCan = true needGold[i]:GetComponent("Text").text =PrintWanNum2(equipSign.Resource[i][2])--string.format("%s", equipSign.Resource[i][2]) end end end end function this.ShowTitleEquipData(_go,_id,index) if not _go and index then _go = needSoulPrint[index] end local ishaveData = false if _id and _id~=0 then ishaveData = true end Util.GetGameObject(_go.transform,"frame"):SetActive(ishaveData) Util.GetGameObject(_go.transform,"icon"):SetActive(ishaveData) Util.GetGameObject(_go.transform,"circleFrameBg"):SetActive(false) Util.GetGameObject(_go.transform,"name"):SetActive(false) if equipSign and _id and _id~=0 then Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(equipSign[_id].Quality)) Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[_id].ResourceID)) Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text = GetLanguageStrById(equipSign.Name) -- if index then -- materialState[index] = {state = true,equipSignConFig = equipSign} -- end if index then selectUpList[index]=_id end else if index then Util.GetGameObject(_go.transform,"addImage"):SetActive(not ishaveData) Util.GetGameObject(_go.transform,"frame"):SetActive(false) Util.GetGameObject(_go.transform,"icon"):SetActive(false) end end end function this.SingleItemDataShow(_go,_curequipSign) if not allGo[_go] then allGo[_go] = _go Util.AddParticleSortLayer(_go, sortingOrder) end local curequipSign = _curequipSign Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(curequipSign.Quality)) local icon=Util.GetGameObject(_go.transform,"icon") icon:SetActive(true) icon:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[curequipSign.Id].ResourceID)) Util.GetGameObject(_go.transform,"circleFrameBg/Icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[curequipSign.Id].ResourceID)) Util.GetGameObject(_go.transform,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[curequipSign.Id].Quantity].circle) Util.GetGameObject(_go.transform,"circleFrameBg"):SetActive(false) --:GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[curequipSign.Id].Quantity].circleBg2) Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text= SubString2(string.gsub(GetLanguageStrById(curequipSign.Name),Language[11520],""),6);--curequipSign.Name Util.GetGameObject(_go.transform, "UI_effect_WuCai_Kuang"):SetActive(curequipSign.Quality == 7) local choosed =Util.GetGameObject(_go.transform, "choosed") choosed:SetActive(curSelectSoulPrint.Id == curequipSign.Id) --local redPoint = Util.GetGameObject(_go.transform,"redPoint") Util.GetGameObject(_go.transform,"redPoint"):SetActive(false) if curSelectSoulPrint.Id == curequipSign.Id then curSelectGO = _go end Util.AddOnceClick(Util.GetGameObject(_go.transform,"frame"), function() if curSelectSoulPrint.Id == curequipSign.Id then return else curSelectSoulPrint = curequipSign choosed:SetActive(true) if curSelectGO then Util.GetGameObject(curSelectGO.transform, "choosed"):SetActive(false) curSelectGO = _go end this.StartCompoundSoulPrint(curequipSign,true) end end) end function this.StartCompoundSoulPrint(curequipSign, isClearSelect) this.ShowTitleEquipData(this.compoundSoulPrint, curequipSign.Id) this.ShowGoldNum(curequipSign) if isClearSelect then materialState = {} for i = 1, 3 do this.ShowTitleEquipData(needSoulPrint[i],0,i) end end end function this.Compound() --LogError(" `````````````````` "..curIndex.." "..curSelectEquip.Star.." "..compoundNum) local list={} for i=1, #selectUpList do if selectUpList[i]~=0 then table.insert(list,selectUpList[i]) end end if #list<3 then PopupTipPanel.ShowTip(Language[10395]) return end if not materidaIsCan then UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.Gold }) return end NetManager.ComplexSoulPrintRequest(curSelectSoulPrint.Id,list,function(msg) -- SoundManager.PlaySound(SoundConfig.UI_Duanzao) SoundManager.PlaySound(SoundConfig.UI_Baoqi) --删除魂印 UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function() this.StartCompoundSoulPrint(curSelectSoulPrint, true) end) end) end function this.AutoSelectSoulPrint() this.StartCompoundSoulPrint(curSelectSoulPrint, true) --local isShowUpHero = SoulPrintManager.GetIsShowUpHeroSoulPrintPlayerPrefs() local datas = BagManager.GetBagItemDataByItemType(itemType) local curBagSoulPrintDatas = {} local maxNum=0 for i = 1, #datas do if equipSign[datas[i].id].Quality == curSelectSoulPrint.Formula[1][1] then for j=1,datas[i].num do if maxNum==3 then break end table.insert(curBagSoulPrintDatas,datas[i]) maxNum=maxNum+1 end end end table.sort(curBagSoulPrintDatas, function(a,b) return equipSign[a.id].Quality < equipSign[b.id].Quality end) for i = 1, 3 do if curBagSoulPrintDatas[i] then this.ShowTitleEquipData(needSoulPrint[i],curBagSoulPrintDatas[i].id,i) end end end function this:OnClose() end function this:OnDestroy() this.spLoader:Destroy() allGo = {} end return this