require("Base/BasePanel") MissionDailyPanel = Inherit(BasePanel) local this = MissionDailyPanel --子模块脚本 local contentScripts = { --日常 [1] = {view = require("Modules/Mission/MissionDailyPanel_Daily"), panelName = "MissionDailyPanel_Daily",type=1}, [2] = {view = require("Modules/Mission/MissionDailyPanel_QingLongSecretTreasure"), panelName = "MissionDailyPanel_QingLongSecretTreasure",type=2}, [3] = {view = require("Modules/Mission/MissionDailyPanel_SecretTreasureTrail"), panelName = "MissionDailyPanel_SecretTreasureTrail",type=3} , --成就 [4] = {view = require("Modules/Mission/MissionDailyPanel_Achievement"), panelName = "MissionDailyPanel_Achievement",type=4}, } local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = Language[11315],type = -1 }, [2] = {default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = Language[11316] ,type = ActivityTypeDef.TreasureOfSomeBody }, [3] = { default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = Language[11317] ,type = ActivityTypeDef.TreasureOfSomeBody }, [4] = { default = "UI_hz_gonghui_19", select = "UI_hz_gonghui_18", name = Language[11318],type = -1 }, } local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)} --子模块预设 local contentPrefabs={} --打开弹窗索引 local index=0 local type = 0 --0 日常 1青龙 local redPointList --初始化组件(用于子类重写) function MissionDailyPanel:InitComponent() this.tabBox = Util.GetGameObject(self.gameObject, "TabBox") this.TabCtrl = TabBox.New() this.mask = Util.GetGameObject(self.transform, "mask") this.closeBtn = Util.GetGameObject(self.transform, "bg/closeBtn") this.titleText = Util.GetGameObject(self.transform, "bg/titleText"):GetComponent("Text") this.contents = Util.GetGameObject(self.transform, "Contents") --子模块脚本初始化 for i = 1, #contentScripts do contentScripts[i].view:InitComponent(Util.GetGameObject(this.contents, contentScripts[i].panelName)) this.spLoader = SpriteLoader.New() end --预设赋值 for i=1,#contentScripts do contentPrefabs[i]=Util.GetGameObject(this.contents,contentScripts[i].panelName) end end --绑定事件(用于子类重写) function MissionDailyPanel:BindEvent() Util.AddClick(this.closeBtn, function() self:ClosePanel() end) Util.AddClick(this.mask, function() self:ClosePanel() end) for i = 1, #contentScripts do contentScripts[i].view:BindEvent() end end --添加事件监听(用于子类重写) function MissionDailyPanel:AddListener() for i = 1, #contentScripts do contentScripts[i].view:AddListener() end end --移除事件监听(用于子类重写) function MissionDailyPanel:RemoveListener() for i = 1, #contentScripts do contentScripts[i].view:RemoveListener() end end --界面打开时调用(用于子类重写) function MissionDailyPanel:OnOpen(popupType,...) --根据传入类型打开对应面板 index = popupType local temp = {...} if temp and temp[1] then type = temp[1] else type = 0 end if not index then index = 1 type = 0 if RedPointManager.GetRedPointMissionDaily() then index = 1 type = 0 elseif ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) and ActivityGiftManager.IsQualifiled( ActivityTypeDef.TreasureOfSomeBody) then if QinglongSerectTreasureManager.GetQinglongSerectTreasureRedPot() then index = 2 type = 1 elseif QinglongSerectTreasureManager.GetSerectTreasureTrailRedPot() then index = 3 type = 1 end elseif TaskManager.GetAchievementState() then index = 4 type = 0 end end for i=1,#contentPrefabs do contentPrefabs[i].gameObject:SetActive(false) end if index ~=1 and type == 0 then index = 4 end contentPrefabs[index].gameObject:SetActive(true) contentScripts[index].view:OnShow(this,...)--1、传入自己 2、传入不定参 end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function MissionDailyPanel:OnShow() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:Init(this.tabBox, _TabData, index) redPointList = {} for i = 1, Util.GetGameObject(this.tabBox,"box").transform.childCount do redPointList[i] =Util.GetGameObject(Util.GetGameObject(this.tabBox,"box").transform:GetChild(i-1).gameObject,"Redpot") redPointList[i]:SetActive(false) end if redPointList[1] and redPointList[2] and redPointList[3] and redPointList[4] then BindRedPointObject(RedPointType.DailyTask, redPointList[1]) BindRedPointObject(RedPointType.QinglongSerectTreasure, redPointList[2]) BindRedPointObject(RedPointType.QinglongSerectTreasureTrail, redPointList[3]) BindRedPointObject(RedPointType.Achievement_Main, redPointList[4]) end end function MissionDailyPanel:OnSortingOrderChange() for i = 1, #contentScripts do contentScripts[i].view:OnSortingOrderChange(self.sortingOrder) 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] if _TabData[index].type ~= -1 then if ActivityGiftManager.IsQualifiled( _TabData[index].type) and ActivityGiftManager.GetActivityOpenStatus( _TabData[index].type) then tab.gameObject:SetActive(true) else tab.gameObject:SetActive(false) end else tab.gameObject:SetActive(true) end end --切换视图 function this.SwitchView(_index) if _index == 2 or _index == 3 then if not ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.TreasureOfSomeBody) then PopupTipPanel.ShowTip(Language[10773]) return end end --先执行上一面板关闭逻辑 local oldSelect oldSelect, index = index, _index for i = 1, #contentScripts do if oldSelect~=0 then contentScripts[oldSelect].view:OnClose() break end end --切换预设显隐 for i = 1, #contentPrefabs do contentPrefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐 end --执行子模块初始化 contentScripts[index].view:OnShow(this) if index == 1 then this.titleText.text = Language[11315] elseif index == 2 then this.titleText.text = Language[11316] elseif index == 3 then this.titleText.text = Language[11317] elseif index == 4 then this.titleText.text = Language[11319] end end --界面关闭时调用(用于子类重写) function MissionDailyPanel:OnClose() for i = 1, #contentScripts do contentScripts[i].view:OnClose() end ClearRedPointObject(RedPointType.DailyTask) ClearRedPointObject(RedPointType.Achievement_Main) ClearRedPointObject(RedPointType.QinglongSerectTreasure) ClearRedPointObject(RedPointType.QinglongSerectTreasureTrail) end --界面销毁时调用(用于子类重写) function MissionDailyPanel:OnDestroy() for i = 1, #contentScripts do contentScripts[i].view:OnDestroy() this.spLoader:Destroy() end end return MissionDailyPanel