---- 魂印图鉴 ---- require("Base/BasePanel") SoulPrintHandBook = Inherit(BasePanel) local this = SoulPrintHandBook local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig) local orginLayer=0--层级 local allSoulPrintData={}--所有魂印数据 local curIndex = 0--当前选择索引 local chooseNum = 0 local tabs = {} local itemData = {} local currentDataList = {} local chooseIdList = {} local list={} function SoulPrintHandBook:InitComponent() this.spLoader = SpriteLoader.New() this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn") this.mask = Util.GetGameObject(this.gameObject, "mask") for i = 1, 5 do tabs[i] = Util.GetGameObject(this.gameObject, "Tabs/Btn" .. i) if i<3 then tabs[i]:SetActive(false) end end this.selectBtn = Util.GetGameObject(this.gameObject, "Tabs/selectBtn") this.selectBtnText = Util.GetGameObject(this.selectBtn.transform, "Text"):GetComponent("Text") this.scrollRoot=Util.GetGameObject(this.gameObject,"ScrollRoot") this.pre=Util.GetGameObject(this.scrollRoot,"Pre") this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollRoot.transform,this.pre, nil,-- Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,4,Vector2.New(50,15)) this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0) this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 end function SoulPrintHandBook:BindEvent() --tab按钮点击 for i = 1, 5 do Util.AddClick(tabs[i], function() if (curIndex == i) then -- this.selectBtn:SetActive(false) -- curIndex = 0 return end curIndex = i this.OnRefresh(curIndex) this:SetSelect() end) end --关闭页面 Util.AddClick(this.backBtn, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) --关闭页面 Util.AddClick(this.mask, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) end function SoulPrintHandBook:AddListener() end function SoulPrintHandBook:RemoveListener() end function SoulPrintHandBook:OnSortingOrderChange() --特效层级重设 for _, v in pairs(list) do Util.SetParticleSortLayer(v, this.sortingOrder+1) end orginLayer = self.sortingOrder end function SoulPrintHandBook:OnOpen() end function SoulPrintHandBook:OnShow() this.GetAllData() curIndex=4 this.OnRefresh(curIndex) this.SetBottomBarIsActive() this:SetSelect() end function SoulPrintHandBook:SetSelect() this.selectBtn:SetActive(true) this.selectBtn.transform.localPosition = tabs[curIndex].transform.localPosition this.selectBtnText.text = Util.GetGameObject(tabs[curIndex].transform, "Text"):GetComponent("Text").text end function this.GetAllData() allSoulPrintData = {} local allCurSoulPrintData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",5) for i = 1, #allCurSoulPrintData do local curSpiritAnimalBook -- for _, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.SpiritAnimalBook)) do -- if configInfo.FetterType == 2 and configInfo.Teamers and configInfo.Teamers[1] and configInfo.Teamers[1][1] == allCurSoulPrintData[i].Id then -- curSpiritAnimalBook = configInfo -- break -- end -- end -- if curSpiritAnimalBook then--表里只有高品质 所以低品质直接添加 -- if PlayerManager.level >= curSpiritAnimalBook.OpenLevel then -- table.insert(allSoulPrintData,allCurSoulPrintData[i]) -- end -- else table.insert(allSoulPrintData,allCurSoulPrintData[i]) --end end end --特殊的开启条件 function this.SetBottomBarIsActive() for i = 1, #tabs do --为白金魂印定开启规则 -- if i == 4 then -- local num = ConfigData[89].Value -- tabs[i]:SetActive(PlayerManager.level >= tonumber(num)) -- end end end function SoulPrintHandBook:OnClose() this.selectBtn:SetActive(false) end function SoulPrintHandBook:OnDestroy() this.spLoader:Destroy() list = {} this.scrollView=nil end local orginLayer2=0 --打开页面时,页面数据刷新 function this.OnRefresh(index) local tempData={} -- local num = ConfigData[89].Value if index==0 then -- if PlayerManager.level >= tonumber(num) then--达到80级才显示白色魂印 tempData=allSoulPrintData -- else -- for i,v in ipairs(allSoulPrintData) do -- if v.Quality ~= 7 then -- table.insert(tempData, v) -- end -- end -- end else for i,v in ipairs(allSoulPrintData) do if v.Quality==(index+3) then table.insert( tempData, v) end end end --预设容器 this.scrollView:SetData(tempData,function(index,root) this.SetScrollPre(root,tempData[index]) list[root] = root end) this.scrollView:SetIndex(1) orginLayer2 = this.sortingOrder orginLayer = this.sortingOrder end --设置预设 function this.SetScrollPre(root,data) Util.SetParticleSortLayer(root, this.sortingOrder+1) SetSoulEffect(itemConfig[data.Id].Quantity1,root) local frame=Util.GetGameObject(root,"Frame"):GetComponent("Image") local icon=Util.GetGameObject(root,"circleFrameBg/Icon"):GetComponent("Image") local name=Util.GetGameObject(root,"Name"):GetComponent("Text") Util.AddOnceClick(root,function() UIManager.OpenPanel(UIName.SoulPrintPopUp,3,nil,data.Id,nil) end) frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(data.Quality)) icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[data.Id].ResourceID)) Util.GetGameObject(root,"circleFrameBg"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circleBg2) Util.GetGameObject(root,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circle) local str = data.Name if GetCurLanguage() == 0 and LengthString(data.Name)>=5 then str = SubString(data.Name,4).."..." end name.text = str--SubString2(GetLanguageStrById(data.Name),10) end return SoulPrintHandBook