----- 送神弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local heros=nil local confirmFunc=nil local currPro=0 local curPage = 1 local type=1 local curZanId=0 local fiveHero={} local newHeroId=0 local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig) local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig) local hotRankConfig=ConfigManager.GetConfig(ConfigName.HotRanking) local specialConfig=ConfigManager.GetConfigData(ConfigName.SpecialConfig,152) local TabBox = require("Modules/Common/TabBox") local _TabData={ -- [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "人气热榜" }, -- [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "山河社稷图" }, -- [3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "心魔试炼" }, -- [4] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "大闹天宫" }, } local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1), select = Color.New(255 / 255, 255 / 255, 255 / 255, 1)} function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") this.prefab=Util.GetGameObject(gameObject,"ItemPre") --滚动条根节点 this.newObj=Util.GetGameObject(gameObject,"new") this.root = Util.GetGameObject(gameObject, "Root") this.root2 = Util.GetGameObject(gameObject, "Root2") this.preList={} this.tabbox= Util.GetGameObject(gameObject, "TabBox") local natural=tonumber(specialConfig.Value) for _, config in ConfigPairs(heroConfig) do if config.Natural>=natural and config.Id~=21061 and config.Hide==0 and config.Newhero==0 then table.insert(fiveHero,config.Id) end if config.Newhero==1 then newHeroId=config.Id end end local parObj=nil if newHeroId==0 then parObj=this.root2 this.newObj:SetActive(false) else parObj=this.root this.newObj:SetActive(true) end this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, parObj.transform, this.prefab,nil, Vector2.New(parObj.transform.rect.width,parObj.transform.rect.height), 1, 1,Vector2.New(20,10)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 2 this.ScrollView.elastic = false this.selectBar = Util.GetGameObject(gameObject,"pros/Grid") this.light = Util.GetGameObject(gameObject,"pros/SelectBtn") this.light:SetActive(true) this.newIcon=Util.GetGameObject(gameObject,"new/icon"):GetComponent("Image") this.newPro=Util.GetGameObject(gameObject,"new/pro"):GetComponent("Image") this.newName=Util.GetGameObject(gameObject,"new/name"):GetComponent("Text") this.des1=Util.GetGameObject(gameObject,"new/des1"):GetComponent("Text") this.des2=Util.GetGameObject(gameObject,"new/des2"):GetComponent("Text") this.hint=Util.GetGameObject(gameObject,"new/hint"):GetComponent("Text") this.btnList = {} for i = 1, 6 do this.btnList[i] = Util.GetGameObject(this.selectBar,"Btn"..i) local name=Util.GetGameObject(this.btnList[i],"Text"):GetComponent("Text") name.text=PropertyType[i-1] end for index, config in ConfigPairs(hotRankConfig) do if config.Open==1 then local rank={} rank.default="UI_hz_gonghui_19" rank.select="UI_hz_gonghui_18" rank.name=config.HeroID rank.id=config.Id table.insert(_TabData,rank) end end this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:Init(this.tabbox, _TabData) end function this:BindEvent() -- LogError("1111111111111111") for i = 1, 6 do Util.AddClick(this.btnList[i],function() if curPage ~= i then this:Refresh(i) end end) end end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status]) Util.GetGameObject(tab,"Image"):GetComponent("Image"):SetNativeSize() tabLab:GetComponent("Text").text = _TabData[index].name tabLab:GetComponent("Text").color = _TabFontColor[status] end local allHeros={} --切换视图 function this.SwitchView(index) --先执行上一面板关闭逻辑 --local oldSelect --oldSelect, curIndex = curIndex, index -- for i = 1, #this.contents do -- if oldSelect~=0 then this.contents[oldSelect].view:OnClose() break end -- end --切换预设显隐 -- for i = 1, #this.prefabs do -- this.prefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐 -- end type=_TabData[index].id NetManager.UserLikeHeroRankRequest(type,function(msg1) if msg1.heroTid and #msg1.heroTid>0 then LogError("msg1.heroTid len=="..#msg1.heroTid) curZanId=msg1.heroTid[1] else curZanId=0 end NetManager.RequestRankInfo(RANK_TYPE.HotHero,function(msg) LogError("发送请求--------------"..index.." id==".._TabData[index].id) allHeros={} local ids={} for i = 1, #msg.ranks do local heroId=msg.ranks[i].rankInfo.param1 --LogError("i=="..i.." heroid=="..heroId) table.insert(ids,heroId) if heroConfig[heroId]~=nil then table.insert(allHeros,{id=heroId,power=msg.ranks[i].rankInfo.param2,pro=heroConfig[heroId].PropertyName}) end end for i = 1, #fiveHero do if not BattleUtil.ChecklistIsContainValue(ids,fiveHero[i]) then --LogError("fiveHero[i]=="..fiveHero[i]) table.insert(allHeros,{id=fiveHero[i],power=0,pro=heroConfig[fiveHero[i]].PropertyName}) end end --this:ShowHeroList(0) this:Refresh(1) end,_TabData[index].id,1,1) end) --执行子模块初始化 -- this.contents[index].view:OnShow(this) end local list={} function this:ShowHeroList(_pro) if not allHeros then return end list={} if _pro==0 then list=allHeros else for key, value in pairs(allHeros) do if value.pro==_pro then table.insert(list,value) end end end this.ScrollView:SetData(list, function(index, go) this.SingleHeroDataShow(go,list[index],index) end) end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,_args) if this.TabCtrl then this.TabCtrl:ChangeTab(1) end this.titleText.text = "英雄热榜" parent=_parent sortingOrder =_parent.sortingOrder if newHeroId~=0 then this.newObj:SetActive(true) local newHeroConfig=heroConfig[newHeroId] this.des1.text=newHeroConfig.HeroLocation this.des2.text=newHeroConfig.HeroLocationDesc1 this.newPro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(newHeroConfig.PropertyName)) this.newName.text = newHeroConfig.ReadingName this.newIcon.sprite = this.spLoader:LoadSprite(artResourcesConfig[newHeroConfig.Icon].Name) this.hint.text="即将上线,敬请期待" Util.AddOnceClick(this.newIcon.gameObject,function() UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, newHeroConfig.Id, newHeroConfig.MaxRank) end) end PlayerPrefs.SetInt(PlayerManager.uid.."hotRank",1) end function this:Refresh(_page) curPage = _page LogError("curpage=="..curPage) currPro=curPage-1 this.light.transform:SetParent(this.btnList[_page].transform) Util.GetGameObject(this.light,"Text"):GetComponent("Text").text=Util.GetGameObject(this.btnList[_page],"Text"):GetComponent("Text").text this.light.transform.localPosition = Vector3.zero this.light.transform.localScale = Vector3.one this:ShowHeroList(currPro) end --英雄单个数据展示 function this.SingleHeroDataShow(go,_heroData,_index) local heroData = _heroData local config=heroConfig[heroData.id] --LogError("herodata id=="..heroData.id) local _go = go -- _go.gameObject:SetActive(true) -- local frame = Util.GetGameObject(_go.transform, "frame"):GetComponent("Image") local name = Util.GetGameObject(_go.transform, "Name"):GetComponent("Text") local icon = Util.GetGameObject(_go.transform, "hero"):GetComponent("Image") local rankImg=Util.GetGameObject(_go.transform, "rankImg"):GetComponent("Image") local rank=Util.GetGameObject(_go.transform, "rank"):GetComponent("Text") local proIcon = Util.GetGameObject(_go.transform, "pro"):GetComponent("Image") local desc=Util.GetGameObject(_go.transform, "Desc"):GetComponent("Text") desc.text=config.HeroLocation local desc2=Util.GetGameObject(_go.transform, "Desc2"):GetComponent("Text") local hot=Util.GetGameObject(_go.transform, "hot") hot:SetActive(false) local btn_zan=Util.GetGameObject(_go.transform, "btn_zan") local numTxt=Util.GetGameObject(_go.transform, "numTxt"):GetComponent("Text") numTxt.text=PrintWanNum(heroData.power) desc2.text=config.HeroLocationDesc1 proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(config.PropertyName)) name.text = config.ReadingName icon.sprite = this.spLoader:LoadSprite(artResourcesConfig[config.Icon].Name) if _index<4 then rankImg.sprite=this.spLoader:LoadSprite("r_Dungeon_00".._index) rank.gameObject:SetActive(false) else rankImg.sprite=this.spLoader:LoadSprite("r_hero_zhuangbeidi") rank.gameObject:SetActive(true) end rank.text=_index Util.SetGray(btn_zan,curZanId~=0) Util.AddOnceClick(icon.gameObject, function() UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, config.Id, config.MaxRank) --UIManager.OpenPanel(UIName.RoleInfoPopup, false, heroData) end) Util.AddOnceClick(btn_zan, function() if curZanId~=0 then return end NetManager.LikeHeroRankRequest(type,heroData.id,function() heroData.power=heroData.power+1 numTxt.text=PrintWanNum(heroData.power) curZanId=heroData.id this.ScrollView:SetData(list, function(index, go) this.SingleHeroDataShow(go,list[index],index) end) this.ScrollView:SetIndex(_index) end) end) end function this:OnClose() curZanId=0 heros=nil CheckRedPointStatus(RedPointType.HotRank) end function this:OnDestroy() this.spLoader:Destroy() this.choosedList = {} this.btnList = {} _TabData={} fiveHero={} end return this