---献祭坛主面板--- require("Base/BasePanel") ResolvePanel = Inherit(BasePanel) local this = ResolvePanel local isSha=false--筛选按钮状态 --Tab local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_31", name = Language[11732] }, -- [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "神将归元" }, -- [3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "法宝归元" }, [2] = { default = "UI_hz_gonghui_32", select = "UI_hz_gonghui_32", name = Language[11603] }, [3] = { default = "UI_hz_gonghui_33", select = "UI_hz_gonghui_33", name = Language[11735] }, [4] = { default = "UI_hz_gonghui_34", select = "UI_hz_gonghui_34", name = "名刀分解" }, } local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1), select = Color.New(255 / 255, 255 / 255, 255 / 255, 1)} --子模块脚本 this.contents = { --献祭 [1] = {view = require("Modules/Resolve/View/Resolve_Dismantle"), panelName = "Resolve_Dismantle"}, --回溯 -- [2] = {view = require("Modules/Resolve/View/Resolve_Recall"), panelName = "Resolve_Recall"}, --法宝归元 -- [3] = {view = require("Modules/Resolve/View/Resolve_Talisman"), panelName = "Resolve_Talisman"}, --宝物分解 [2] = {view = require("Modules/Resolve/View/Resolve_EquipTreasure"), panelName = "Resolve_EquipTreasure"}, --放生灵兽 [3] = {view = require("Modules/Resolve/View/Resolve_Pokemon"), panelName = "Resolve_Pokemon"}, [4] = {view = require("Modules/Resolve/View/Resolve_GodWeapon"), panelName = "Resolve_GodWeapon"}, } --子模块预设 this.prefabs={} --上一子模块索引 local curIndex=0 --Title资源名 local titleImageName={"gongsong_zh","h_xianji_fenjie_zh","lingshou_lingshoufangshengzi_zh","GodWeaponAtlas_fenjie_title_zh"}--,"guiyuan_zh","h_guiyuan_zi_zh" local titleName={Language[11732],"宝物分解",Language[11735],"名刀分解"} local titleColor={Color.New(243 / 255, 235 / 255, 202 / 255, 1),Color.New(243 / 255, 235 / 255, 202 / 255, 1),Color.New(243 / 255, 235 / 255, 202 / 255, 1)} local bgImageName={"UI_hz_ls_01","UI_hz_ls_07","UI_hz_ls_08"}--,"h_huisu_ditu","h_xianji_guiyuanditu" local heroEndBtns = {} local tabSortType function ResolvePanel:InitComponent() this.spLoader = SpriteLoader.New() this.panel = Util.GetGameObject(self.gameObject, "Panel") this.bgIma=Util.GetGameObject(self.gameObject,"Bg"):GetComponent("Image") this.title=Util.GetGameObject(self.gameObject,"Title"):GetComponent("Image") this.titleDes=Util.GetGameObject(this.title.gameObject,"Text"):GetComponent("Text") 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.shaiBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_shenjiang_32") 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, 5 do heroEndBtns[i]=Util.GetGameObject(this.panel, "endTabs/btnHeroGrid/btnHeroGrid/Btn"..i-1) Util.GetGameObject(heroEndBtns[i],"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyIcon[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() print(Language[12153]..tabSortType) if tabSortType == i-1 then tabSortType = 0 this.contents[curIndex].view.SortTypeClick(this.sortingOrder,0)--全部 this.EndTabBtnSelect() else tabSortType = i-1 this.contents[curIndex].view.SortTypeClick(this.sortingOrder,i-1) this.EndTabBtnSelect(heroEndBtns[i]) end PlayerManager.now_index = tabSortType print(Language[12154]..tabSortType) 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 this.RewardGridGoMov(false) PlayerManager.now_index = 0 this.EndTabBtnSelect() end function ResolvePanel:OnDestroy() this.spLoader:Destroy() for i = 1, #this.contents do this.contents[i].view:OnDestroy() end end --切换视图 function this.SwitchView(index,isNotTop,isNotAni) --先执行上一面板关闭逻辑 local oldSelect oldSelect, curIndex = curIndex, index if oldSelect ~= curIndex then -- body this.RewardGridGoMov(false) isSha = false PlayerManager.now_index = 0 end 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 --区分显示 this.shaiBtn:SetActive(true) if index==1 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeartFireStone}) this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[1]) this.title.sprite=this.spLoader:LoadSprite(titleImageName[1]) this.titleDes.text=titleName[1] -- elseif index==2 then -- this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) -- this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[2]) -- this.title.sprite=this.spLoader:LoadSprite(titleImageName[2]) -- elseif index==3 then -- this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) -- this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3]) -- this.title.sprite=this.spLoader:LoadSprite(titleImageName[3]) elseif index==2 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[2]) this.title.sprite=this.spLoader:LoadSprite(titleImageName[2]) this.titleDes.text=titleName[2] elseif index==3 then this.shaiBtn:SetActive(false) this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3]) this.title.sprite=this.spLoader:LoadSprite(titleImageName[3]) this.titleDes.text=titleName[3] elseif index==4 then this.shaiBtn:SetActive(false) this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn}) this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3]) this.title.sprite=this.spLoader:LoadSprite(titleImageName[4]) this.titleDes.text=titleName[4] end this.title:SetNativeSize() --执行子模块初始化 this.contents[index].view:OnShow(this.sortingOrder,this.itemListRoot,isNotTop,isNotAni) --刷新选择按钮 tabSortType = 0 this.EndTabBtnSelect(heroEndBtns[PlayerManager.now_index + 1]) 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]) tabLab:GetComponent("Text").text = GetCurLanguage() ~= 2 and _TabData[index].name or "".._TabData[index].name.."" tabLab:GetComponent("Text").color = _TabFontColor[status] Util.GetGameObject(tab,"select"):SetActive(status=="select") this.SetBottomBarIsActive(tab, index) end --特殊的开启条件 function this.SetBottomBarIsActive(tab, index) local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig) if index == 2 then local string = ConfigData[40].Value local num = string.split(string.split(string,"|")[1],"#")[2] tab:SetActive(PlayerManager.level >= tonumber(num)) elseif index == 3 then tab.gameObject:SetActive(ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.POKEMON)) end 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(330, 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(0, 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.New(0.8,-1.3,0) else this.selectHeroBtn.transform:SetParent(heroEndBtns[1].transform) this.selectHeroBtn.transform.localScale = Vector3.one this.selectHeroBtn.transform.localPosition=Vector3.New(0.8,-1.3,0) end end return ResolvePanel