require("Base/BasePanel") local ArenaMainPanel = Inherit(BasePanel) local this = ArenaMainPanel -- Tab管理器 local TabBox = require("Modules/Common/TabBox") local _TabImgData = {select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02",} local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1) } local _TabData = { [1]= {txt = Language[10072]}, -- [2]= {txt = "排名"}, [2]= {txt = Language[10073]}, [3]= {txt = Language[10074]}, } -- 内容数据 local _ViewData = { [1] = {script = "Modules/Arena/View/ArenaView"}, -- [2] = {script = "Modules/Arena/View/RewardView"}, } --初始化组件(用于子类重写) function ArenaMainPanel:InitComponent() this.spLoader = SpriteLoader.New() this.tabbox = Util.GetGameObject(self.gameObject, "tabbox") this.btnBack = Util.GetGameObject(self.gameObject, "rightUp/btnBack") this.content = Util.GetGameObject(self.gameObject, "content") this.ViewList = {} this.ViewList[1] = Util.GetGameObject(self.gameObject, "content/ArenaView") -- this.ViewList[2] = Util.GetGameObject(self.gameObject, "content/RewardView") this.ViewLogicList = {} -- 上部货币显示 this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform, { showType = UpViewOpenType.ShowLeft}) end --绑定事件(用于子类重写) function ArenaMainPanel:BindEvent() -- 初始化Tab管理器 this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.OnTabChange) this.TabCtrl:Init(this.tabbox, _TabData) Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) end --添加事件监听(用于子类重写) function ArenaMainPanel:AddListener() end --移除事件监听(用于子类重写) function ArenaMainPanel:RemoveListener() end --界面打开时调用(用于子类重写) function ArenaMainPanel:OnOpen(...) -- 参数保存 local args = {...} this._CurTabIndex = args[1] or 1 end -- 打开,重新打开时回调 function ArenaMainPanel:OnShow() if this.TabCtrl then this.TabCtrl:ChangeTab(this._CurTabIndex) end --if this._CurLogicIndex then -- this.OpenView(this._CurLogicIndex) --end SoundManager.PlayMusic(SoundConfig.BGM_Arena) end function ArenaMainPanel:OnSortingOrderChange() for index, logic in pairs(this.ViewLogicList) do if logic.OnSortingOrderChange then logic:OnSortingOrderChange(self.sortingOrder) end end end --界面关闭时调用(用于子类重写) function ArenaMainPanel:OnClose() if this._CurLogicIndex then this.CloseView(this._CurLogicIndex) end end --界面销毁时调用(用于子类重写) function ArenaMainPanel:OnDestroy() SubUIManager.Close(this.UpView) -- 清除红点 -- ClearRedPointObject(RedPointType.Arena_Shop) -- 调用销毁方法 for index, logic in pairs(this.ViewLogicList) do if logic.OnDestroy then logic:OnDestroy() end this.spLoader:Destroy() end if this.shopView then this.shopView.gameObject:SetActive(true) -- 重置一下显示状态,避免其他界面打开时状态错误 this.shopView = SubUIManager.Close(this.shopView) this.shopView = nil end end -- tab按钮自定义显示设置 function this.TabAdapter(tab, index, status) local img = Util.GetGameObject(tab, "Image") local txt = Util.GetGameObject(tab, "Text") img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status]) txt:GetComponent("Text").text = _TabData[index].txt txt:GetComponent("Text").color = _TabFontColor[status] -- 判断是否需要检测红点 -- local redpot = Util.GetGameObject(tab, "redpot") -- if index == 3 then -- BindRedPointObject(RedPointType.Arena_Shop, redpot) -- end end -- tab改变回调事件 function this.OnTabChange(index, lastIndex) if lastIndex then this.CloseView(lastIndex) end this.OpenView(index) end -- function this.OpenView(index) this._CurLogicIndex = index this._CurTabIndex = index this.tabbox:SetActive(index ~= 1)--竞技场界面关闭tabbox -- 商店界面特殊处理 -- if index == 3 then -- if not this.shopView then -- this.shopView = SubUIManager.Open(SubUIConfig.ShopView, this.content.transform) -- end -- this.shopView.gameObject:SetActive(true) -- this.shopView:ShowShop(SHOP_TYPE.ARENA_SHOP, this.sortingOrder) -- this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ArenaShop }) -- return -- end local logic = this.ViewLogicList[index] if not logic then this.ViewLogicList[index] = reimport(_ViewData[index].script) logic = this.ViewLogicList[index] logic.gameObject = this.ViewList[index] logic.transform = this.ViewList[index].transform if logic.InitComponent then logic:InitComponent() end if logic.BindEvent then logic:BindEvent() end end if logic.AddListener then logic:AddListener() end if logic.OnOpen then logic:OnOpen(this.sortingOrder,self) end logic.gameObject:SetActive(true) -- 货币界面 this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Arena }) end function this.CloseView(index) if this._CurLogicIndex ~= index then return end -- 商店界面特殊处理 if index == 3 then if this.shopView then this.shopView.gameObject:SetActive(false) end return end local logic = this.ViewLogicList[index] if logic then if logic.RemoveListener then logic:RemoveListener() end if logic.OnClose then logic:OnClose() end logic.gameObject:SetActive(false) end end --跳转显示新手提示圈 function this.ShowGuideGo() JumpManager.ShowGuide(UIName.ArenaMainPanel,Util.GetGameObject(this.gameObject, "content/ArenaView/challengebox/enemy_1/challenge")) end return ArenaMainPanel