----- 易经宝库弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local itemList = {}--克隆预制体列表 local tabs = {} local curIndex = 1 local myHelpHero = {} local selectHelpHero = {} local waveId = 0 local configData = {} function this:InitComponent(gameObject) this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") this.itemPre = Util.GetGameObject(gameObject, "itemPre") this.Scroll = Util.GetGameObject(gameObject, "scroller") this.selectBtn = Util.GetGameObject(gameObject, "tabbox/selectBtn") this.tabRoot = Util.GetGameObject(gameObject, "tabbox/box") for i = 1,#this.tabRoot.transform.childCount do table.insert(tabs,this.tabRoot.transform:GetChild(i - 1).gameObject) end local rootHight = this.Scroll.transform.rect.height local width = this.Scroll.transform.rect.width this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.Scroll.transform, this.itemPre, nil, Vector2.New(width, rootHight), 1, 2, Vector2.New(0, 0)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 2 end function this:BindEvent() for i = 1,#tabs do Util.AddClick(tabs[i],function() this:BtnClick(i) end) end end function this:BtnClick(i) if curIndex == i then return end this.selectBtn.transform:SetParent(tabs[i].transform) this.selectBtn:GetComponent("RectTransform").localPosition = Vector3.zero this.transform:SetAsFirstSibling() curIndex = i if i == 1 then selectHelpHero = {} --向后端发送请求 this:RefreshItemData() else --筛选合适的神将 this:RefreshItemData() end end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,...) parent=_parent sortingOrder = _parent.sortingOrder local args = {...} waveId = args[1] configData = ConfigManager.GetConfigData(ConfigName.CampTowerConfig,waveId) this.titleText.text = configData.CampId.."试炼" myHelpHero = {} this:BtnClick(1) end function this:RefreshItemData() local data = curIndex == 1 and selectHelpHero or myHelpHero table.sort(data,function(a,b) end) this.ScrollView:Setdata(data,function(index,go) this:SetSingleData(index,go,data[index]) end ) end function this:SingleHeroDataShow(_go, _heroData) local heroData = _heroData local go = _go local orderImage= Util.GetGameObject(go, "orderImage") orderImage:SetActive(false) Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality, heroData.star)) Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.icon) Util.GetGameObject(go, "lv/Text"):GetComponent("Text").text = heroData.lv --Util.GetGameObject(go, "posIcon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon) Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName)) --Util.GetGameObject(go, "heroStage"):GetComponent("Image").sprite = Util.LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage]) Util.GetGameObject(go, "heroStage"):SetActive(false) local heroHp = ExpeditionManager.heroInfo[heroData.dynamicId].remainHp local starGrid = Util.GetGameObject(go, "star") SetHeroStars(starGrid, heroData.star) Util.AddOnceClick(go, function() UIManager.OpenPanel(UIName.RoleInfoPopup, heroData) end) end function this:SetSingleData(index,item,data) itemList[index] = item local itemRoot = Util.GetGameObject(item,"HeroPre") local name = Util.GetGameObject(item,"name"):GetComponent("Text") local num = Util.GetGameObject(item,"power/text"):GetComponent("Text") local tip = Util.GetGameObject(item,"tip"):GetComponent("Text") local select = Util.GetGameObject(item,"Button/tip"):GetComponent("Image") local selectText = Util.GetGameObject(item,"Button/Text") local btn = Util.GetGameObject(item,"Button") this:SingleHeroDataShow(itemRoot, data.heroData) name.text = itemConfig[data.heroData.heroConfig.Id].Name num.text = data.power tip.text = "来自"..data.from..data.userName tip.gameObject:SetActive(curIndex == 1) if data.isSelect then btn:GetComponent("Button").enbled = false else btn:GetComponent("Button").enbled = true end Util.AddOnceClick(btn,function() end) end function this:OnClose() end function this:OnDestroy() itemList = {} end return this