----- 编队推荐阵容 ----- require("Base/BasePanel") FormationExamplePopup = Inherit(BasePanel) local this = FormationExamplePopup local recommendConfig=ConfigManager.GetConfig(ConfigName.RecommendTeam) local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig) local tabs = {}--筛选按钮 local proId=1 function FormationExamplePopup:InitComponent() this.spLoader = SpriteLoader.New() this.panel=Util.GetGameObject(this.gameObject,"Panel") this.backBtn = Util.GetGameObject(this.panel, "BackBtn") --筛选按钮 for i = 1, 6 do tabs[i] = Util.GetGameObject(this.panel, "Tabs/Grid/Btn" .. i) end this.selectBtn = Util.GetGameObject(this.panel, "Tabs/SelectBtn") this.scroll=Util.GetGameObject(this.panel,"Scroll") this.scrollPre=Util.GetGameObject(this.panel,"Scroll/Pre") this.scrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, this.scroll.transform, this.scrollPre, Vector2.New(764,854), 1, 10) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 end function FormationExamplePopup:BindEvent() --返回按钮 Util.AddClick(this.backBtn, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) --筛选按钮 for i = 1, 6 do Util.AddClick(tabs[i], function() proId=i this.OnClickTabBtn(i) end) end end function FormationExamplePopup:AddListener() end function FormationExamplePopup:RemoveListener() end function FormationExamplePopup:OnOpen() end function FormationExamplePopup:OnShow() proId=1 PlayerPrefs.SetInt(PlayerManager.uid.."tuijianzhenrong",1) this.OnClickTabBtn(proId) end function FormationExamplePopup:OnClose() CheckRedPointStatus(RedPointType.tuijianzhenrong) end function FormationExamplePopup:OnDestroy() this.spLoader:Destroy() this.scrollView=nil end function this.OnClickTabBtn(_proId) this.selectBtn:SetActive(proId ==_proId) this.selectBtn.transform:SetParent(tabs[_proId].transform) this.selectBtn.transform:DOAnchorPos(Vector3.zero,0) this.selectBtn.transform:DOScale(Vector3.one,0) local curData=ConfigManager.GetAllConfigsDataByKey(ConfigName.RecommendTeam,"Type",proId) local _curData={} for key, value in pairs(curData) do --只显示在编队中的数据 if value.IsShowInTeam==1 then local isHeroOpen = true for i = 1, 6 do local heroId=value.HeroList[i] if not HeroManager.InVersion(heroId) then isHeroOpen = false end end if isHeroOpen then table.insert(_curData,value) end end end table.sort(_curData,function(a,b) return a.Sort" end for n = 1, #_strs do _strs[n]=_strs[n].."\n" end heroDesc.text=string.sub(table.concat(_strs),1,-2)--将表里字符串拼接 去除最后\n end return FormationExamplePopup