require("Base/BasePanel") FaLingListPanel = Inherit(BasePanel) local this = FaLingListPanel local curSelectHeroList={} local heroDataList={} local curNeedRoleNum=1 local openThisPanel local curHeroData = {} local openType=0 --初始化组件(用于子类重写) function FaLingListPanel:InitComponent() this.spLoader = SpriteLoader.New() this.BtnBack = Util.GetGameObject(self.gameObject, "btnBack") this.mask = Util.GetGameObject(self.gameObject, "mask") this.BtnSure = Util.GetGameObject(self.gameObject, "btnSure") this.BtnSure:SetActive(false) this.btnAutoSelect = Util.GetGameObject(self.gameObject, "btnAutoSelect") this.cardPre = Util.GetGameObject(self.gameObject, "item") --this.grid = Util.GetGameObject(self.gameObject, "scroll/grid") local v = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect --LogGreen("v.width:".. v.width.." v.height:"..v.height) this.Scrollbar= Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar") this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,Util.GetGameObject(self.gameObject, "scroll").transform, this.cardPre, this.Scrollbar, Vector2.New(v.width, v.height), 1, 5, Vector2.New(19.32,40)) this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(6.78, 27) 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.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 this.NoneImage= Util.GetGameObject(self.gameObject, "NoneImage") this.NoneImage.gameObject:SetActive(false) end --绑定事件(用于子类重写) function FaLingListPanel:BindEvent() Util.AddClick(this.BtnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) Util.AddClick(this.mask, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) Util.AddClick(this.BtnSure, function() if #curSelectHeroList>0 then if openType==1 then NetManager.BaublesWearRequest(curHeroData.dynamicId,curSelectHeroList[1],nil,function() self:ClosePanel() end) elseif openType==2 then NetManager.BaublesBlessRequest(curHeroData.baublesId,curSelectHeroList[1],function () openThisPanel:OnShow() self:ClosePanel() end) end else self:ClosePanel() end end) Util.AddClick(this.btnAutoSelect, function() self:AutoSelectHero() end) end --添加事件监听(用于子类重写) function FaLingListPanel:AddListener() end --移除事件监听(用于子类重写) function FaLingListPanel:RemoveListener() end --界面打开时调用(用于子类重写) function FaLingListPanel:OnOpen(heroData,_openThisPanel,_curSelectHeroList,_curHeroData,_openType) openThisPanel= _openThisPanel openType=_openType curSelectHeroList={} print(#_curSelectHeroList) for i = 1, #_curSelectHeroList do -- curSelectHeroList[_curSelectHeroList[i]]=_curSelectHeroList[i] table.insert(curSelectHeroList,_curSelectHeroList[i]) end curHeroData = _curHeroData heroDataList = heroData --this.HeroSortData(heroDataList) local text = "" if not heroDataList or #heroDataList < 1 then this.NoneImage.gameObject:SetActive(true) else this.NoneImage.gameObject:SetActive(false) end this.ScrollView:SetData(heroDataList, function (index, go) this.OnShowSingleCardData(go, heroDataList[index]) end,false,false) end function this.OnClickEnterHero(go,heroData,type) this.OnShowSingleCardData(go,heroData,type) end function this.OnShowSingleCardData(go,heroData)--isSelect 1选择 2 没选择 local choosed = Util.GetGameObject(go.transform, "choosed") choosed:SetActive(false) local frame = Util.GetGameObject(go.transform, "frame"):GetComponent("Image") local lvGo = Util.GetGameObject(go.transform, "lv"):GetComponent("Text") local icon = Util.GetGameObject(go.transform, "icon"):GetComponent("Image") local name = Util.GetGameObject(go.transform, "name"):GetComponent("Text") local formationMask = Util.GetGameObject(go.transform, "formationMask") local formationImage = Util.GetGameObject(formationMask.transform, "formationImage") local lockImage = Util.GetGameObject(formationMask.transform, "lockImage") local noumenon = Util.GetGameObject(go, "noumenon") local starGrid = Util.GetGameObject(go.transform, "star") local cardBtn = Util.GetGameObject(go.transform, "icon") LogError("22222222222") local itemConfig=heroData.itemConfig frame.sprite = this.spLoader:LoadSprite(heroData.frame) if heroData.lv>0 then lvGo.gameObject:SetActive(true) lvGo.text=heroData.lv else lvGo.gameObject:SetActive(false) end icon.sprite = this.spLoader:LoadSprite(heroData.icon) formationMask:SetActive(false) formationImage:SetActive(false) lockImage:SetActive(false) name.text = SubString2(GetLanguageStrById(itemConfig.Name),8) local talismana=ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",heroData.staticId,"Level",heroData.lv) local star=talismana.Star if star>0 then starGrid:SetActive(true) local starType=1 local starSize=nil starType=3 star=star+10 starSize = Vector2.New(0.8,-20) local starScale = -20 SetHeroStars(this.spLoader,starGrid, star,starType,starSize,starScale) Util.SetParticleSortLayer(starGrid, this.sortingOrder + 3) else starGrid:SetActive(false) end local isSelect = CheckListIsContainValue1(curSelectHeroList,heroData.did) choosed:SetActive(isSelect) Util.SetParticleSortLayer(starGrid,this.sortingOrder + 1) Util.AddOnceClick(cardBtn, function() -- if isSelect then -- choosed:SetActive(false) -- table.removebyvalue(curSelectHeroList,heroData.did) -- isSelect=false -- return -- end -- if LengthOfTable(curSelectHeroList)>=curNeedRoleNum then -- PopupTipPanel.ShowTip(Language[10403]) -- return -- end -- table.insert(curSelectHeroList,heroData.did) -- isSelect=true -- choosed:SetActive(true) if openType==1 then UIManager.OpenPanel(UIName.FaLingSingleShowPopup,this,heroData,3,false,false,curHeroData) elseif openType==2 then NetManager.BaublesBlessRequest(curHeroData.baublesId,heroData.did,function () openThisPanel:OnShow() this:ClosePanel() end) end end) Util.AddLongPressClick(cardBtn, function() --UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, heroData.id) end, 0.5) end --界面关闭时调用(用于子类重写) function FaLingListPanel:OnClose() end --界面销毁时调用(用于子类重写) function FaLingListPanel:OnDestroy() this.spLoader:Destroy() this.ScrollView = nil end return FaLingListPanel