----- 修行选择英雄弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local func local data function this:InitComponent(gameObject) self.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") self.tip=Util.GetGameObject(gameObject,"tip"):GetComponent("Text") self.scroll = Util.GetGameObject(gameObject, "Scroll") self.confirm = Util.GetGameObject(gameObject, "ConfirmBtn") self.cancel = Util.GetGameObject(gameObject, "CancelBtn") self.itemPre = Util.GetGameObject(gameObject, "itemPre") self.mask = Util.GetGameObject(gameObject, "itemPre/item") -- 设置循环滚动,万一内容不停地加 local rootHight = self.scroll.transform.rect.height local width = self.scroll.transform.rect.width self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform, self.itemPre, nil, Vector2.New(width, rootHight), 1, 4, Vector2.New(20, 35)) self.scrollView.moveTween.MomentumAmount = 1 self.scrollView.moveTween.Strength = 2 self.heroList={} self.itemList = {} self.maskList = {} end function this:BindEvent() Util.AddClick(this.confirm,function() parent:ClosePanel() if func then func(self.heroD) end end) Util.AddClick(this.cancel,function() parent:ClosePanel() end) end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,...) parent=_parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 local _args = {...} data = _args[1] func = _args[2] self.heroList = HeroManager.GetHeroDataByPropertyAndProfession(data.FitList[1],data.FitList[2],5) table.sort(self.heroList,function (a,b) return a.warPower > b.warPower end) this:Refresh(true,true) end function this:Refresh(isTop,isAni) this.titleText.text = "神印附身" if not self.itemList then self.itemList = {} end for i = 1, #self.itemList do self.itemList[i].gameObject:SetActive(false) end -- LogRed("#self.heroList:"..tostring(#self.heroList)) self.scrollView:SetData(self.heroList, function (index, item) this:ShowSingleData(item, self.heroList[index],index) end,not isTop,not isAni) if #self.heroList ~= 0 then this.tip.text = "请选择您要附身的神将" self.tip.gameObject:GetComponent("RectTransform").localPosition = Vector3.New(0,232,0) else self.tip.text = "暂无可附身的神将" self.tip.gameObject:GetComponent("RectTransform").localPosition = Vector3.zero end end function this:ShowSingleData(go,heroData,index) self.itemList[index] = go 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, "icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.icon) Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName)) local starGrid = Util.GetGameObject(go, "star") local starPre = Util.GetGameObject(go, "starPre") self.maskList[index] = Util.GetGameObject(go, "choosed") -- LogGreen("data.UnlockId:"..tostring(data.UnlockId)) self.maskList[index]:SetActive(tostring(PracticeManager.ImprintServerData[data.Id].subId) == tostring(heroData.dynamicId)) SetHeroStars(starGrid, heroData.star) Util.AddOnceClick(go, function() -- LogGreen("subId:"..tostring(PracticeManager.ImprintServerData[data.Id].subId).." did:"..tostring(heroData.dynamicId)) for i = 1, #self.maskList do self.maskList[i]:SetActive(false) end self.maskList[index]:SetActive(true) self.heroD = heroData end) Util.AddLongPressClick(go, function() UIManager.OpenPanel(UIName.RoleInfoPopup, heroData) end, 0.5) end function this:OnClose() self.selectId = nil self.heroList={} self.maskList = {} end function this:OnDestroy() self.itemList = {} end return this