---献祭坛主面板--- require("Base/BasePanel") ResolvePanel = Inherit(BasePanel) local this = ResolvePanel local isSha=false--筛选按钮状态 --Tab local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[11785] }, [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[11786] }, [3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[12212] }, } local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)} --子模块脚本 this.contents = { --回溯 [1] = {view = require("Modules/Resolve/View/Resolve_Recall"), panelName = "Resolve_Recall"}, --献祭 [2] = {view = require("Modules/Resolve/View/Resolve_Dismantle"), panelName = "Resolve_Dismantle"}, --宝物分解 [3] = {view = require("Modules/Resolve/View/Resolve_EquipTreasure"), panelName = "Resolve_EquipTreasure"}, } --子模块预设 this.prefabs={} --上一子模块索引 local curIndex=0 --Title资源名 local titleImageName={"guiyuan","gongsong","h_xianji_fenjie"} local heroEndBtns = {} local tabSortType function ResolvePanel:InitComponent() this.panel = Util.GetGameObject(self.gameObject, "Panel") this.title=Util.GetGameObject(self.gameObject,"Title"):GetComponent("Image") this.backBtn = Util.GetGameObject(this.panel, "BackBtn") this.content = Util.GetGameObject(this.panel, "Content") this.itemListRoot=Util.GetGameObject(this.panel,"ItemListRoot") this.shaiBtn = Util.GetGameObject(this.panel, "leftUp/shaiBtn") this.btnHeroGrid = Util.GetGameObject(this.panel, "endTabs/btnHeroGrid") this.endTabs = Util.GetGameObject(this.panel, "endTabs") this.endTabs:SetActive(false) --预设赋值 for i=1,#this.contents do this.prefabs[i]=Util.GetGameObject(this.panel,this.contents[i].panelName) end this.selectHeroBtn = Util.GetGameObject(this.panel, "endTabs/selectBtn") for i = 1, 6 do heroEndBtns[i]=Util.GetGameObject(this.panel, "endTabs/btnHeroGrid/btnHeroGrid/Btn"..i-1) end for i = 1, #this.contents do this.contents[i].view:InitComponent(this.panel) end end function ResolvePanel:BindEvent() for i = 1, #this.contents do this.contents[i].view:BindEvent() end --返回按钮 Util.AddClick(this.backBtn,function() if isSha then isSha=not isSha this.RewardGridGoMov(isSha,function() self:ClosePanel() end) else self:ClosePanel() end end) Util.AddClick(this.shaiBtn, function() isSha=not isSha this.RewardGridGoMov(isSha) end) for i = 1, 6 do Util.AddClick( heroEndBtns[i], function() if tabSortType == i-1 then tabSortType = 0 this.contents[curIndex].view.SortTypeClick(0)--全部 this.EndTabBtnSelect() else tabSortType = i-1 this.contents[curIndex].view.SortTypeClick(i-1) this.EndTabBtnSelect(heroEndBtns[i]) end end) end end function ResolvePanel:AddListener() for i = 1, #this.contents do this.contents[i].view:AddListener() end end function ResolvePanel:RemoveListener() for i = 1, #this.contents do this.contents[i].view:RemoveListener() end end function ResolvePanel:OnSortingOrderChange() this.sortingOrder = self.sortingOrder end function ResolvePanel:OnOpen(...) local args = {...} if args[1] then curIndex=args[1] else curIndex=1 end tabSortType = 0 this.EndTabBtnSelect() end function ResolvePanel:OnShow() this.upView = SubUIManager.Open(SubUIConfig.UpView, self.transform, {showType = UpViewOpenType.ShowLeft}) this.tabBox = Util.GetGameObject(this.panel, "TabBox") this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:Init(this.tabBox, _TabData,curIndex) end function ResolvePanel:OnClose() SubUIManager.Close(this.upView) for i = 1, #this.contents do this.contents[i].view:OnClose() end end function ResolvePanel:OnDestroy() for i = 1, #this.contents do this.contents[i].view:OnDestroy() end end --切换视图 function this.SwitchView(index) this.RewardGridGoMov(false) --先执行上一面板关闭逻辑 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 --区分显示 if index==1 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) this.title.sprite=Util.LoadSprite(titleImageName[1]) elseif index==2 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeartFireStone}) this.title.sprite=Util.LoadSprite(titleImageName[2]) elseif index==3 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeartFireStone}) this.title.sprite=Util.LoadSprite(titleImageName[3]) end this.title:SetNativeSize() --执行子模块初始化 this.contents[index].view:OnShow(this.sortingOrder,this.itemListRoot) --刷新选择按钮 tabSortType = 0 this.EndTabBtnSelect() end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status]) tabLab:GetComponent("Text").text = _TabData[index].name tabLab:GetComponent("Text").color = _TabFontColor[status] end function this.RewardGridGoMov(isSha,fun) this.shaiBtn:GetComponent("Button").enabled = false if isSha then this.endTabs:SetActive(true) --this.btnHeroGrid.transform:DOAnchorPosY(-670, 0.5, false) this.endTabs.transform:DOAnchorPosY(251.62, 0.5, false):OnComplete(function() this.shaiBtn:GetComponent("Button").enabled = true if fun then fun() end end) else --this.btnHeroGrid.transform:DOAnchorPosY(-766, 0.5, false) this.endTabs.transform:DOAnchorPosY(-38.64, 0.5, false):OnComplete(function() this.shaiBtn:GetComponent("Button").enabled = true this.endTabs:SetActive(false) if fun then fun() end end) end end --下部页签排序 function this.EndTabBtnSelect(_btn) -- this.selectHeroBtn:SetActive(tabSortType > 0) if _btn then this.selectHeroBtn.transform:SetParent(_btn.transform) this.selectHeroBtn.transform.localScale = Vector3.one this.selectHeroBtn.transform.localPosition=Vector3.zero else this.selectHeroBtn.transform:SetParent(heroEndBtns[1].transform) this.selectHeroBtn.transform.localScale = Vector3.one this.selectHeroBtn.transform.localPosition=Vector3.zero end end return ResolvePanel