2020-05-09 13:31:21 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
MissionDailyPanel = Inherit(BasePanel)
|
|
|
|
|
local this = MissionDailyPanel
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--子模块脚本
|
|
|
|
|
local contentScripts = {
|
|
|
|
|
--日常
|
|
|
|
|
[1] = {view = require("Modules/Mission/MissionDailyPanel_Daily"), panelName = "MissionDailyPanel_Daily",type=1},
|
|
|
|
|
--成就
|
|
|
|
|
[2] = {view = require("Modules/Mission/MissionDailyPanel_Achievement"), panelName = "MissionDailyPanel_Achievement",type=2},
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
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 = "成 就" }, }
|
|
|
|
|
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
|
|
|
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
|
|
|
|
|
--子模块预设
|
|
|
|
|
local contentPrefabs={}
|
|
|
|
|
--打开弹窗索引
|
|
|
|
|
local index=0
|
|
|
|
|
local redPointList
|
|
|
|
|
--初始化组件(用于子类重写)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function MissionDailyPanel:InitComponent()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
|
|
|
|
|
this.TabCtrl = TabBox.New()
|
|
|
|
|
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))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--预设赋值
|
|
|
|
|
for i=1,#contentScripts do
|
|
|
|
|
contentPrefabs[i]=Util.GetGameObject(this.contents,contentScripts[i].panelName)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:BindEvent()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.AddClick(this.closeBtn, function()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:BindEvent()
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:AddListener()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:AddListener()
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:RemoveListener()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:RemoveListener()
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function MissionDailyPanel:OnOpen(popupType,...)
|
|
|
|
|
--根据传入类型打开对应面板
|
|
|
|
|
index = popupType or 1
|
|
|
|
|
--for i,v in pairs(contentScripts) do
|
|
|
|
|
-- if popupType==v.type then
|
|
|
|
|
-- index=i
|
|
|
|
|
-- break
|
|
|
|
|
-- end
|
|
|
|
|
--end
|
|
|
|
|
for i=1,#contentPrefabs do
|
|
|
|
|
contentPrefabs[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
contentPrefabs[index].gameObject:SetActive(true)
|
|
|
|
|
contentScripts[index].view:OnShow(this,...)--1、传入自己 2、传入不定参
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:OnShow()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
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)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if redPointList[1] and redPointList[2] then
|
|
|
|
|
BindRedPointObject(RedPointType.DailyTask, redPointList[1])
|
|
|
|
|
BindRedPointObject(RedPointType.Achievement_Main, redPointList[2])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function MissionDailyPanel:OnSortingOrderChange()
|
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:OnSortingOrderChange()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
-- 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.SwitchView(_index)
|
|
|
|
|
--先执行上一面板关闭逻辑
|
|
|
|
|
local oldSelect
|
|
|
|
|
oldSelect, index = index, _index
|
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
if oldSelect~=0 then contentScripts[oldSelect].view:OnClose() break end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--切换预设显隐
|
|
|
|
|
for i = 1, #contentPrefabs do
|
|
|
|
|
contentPrefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--执行子模块初始化
|
|
|
|
|
contentScripts[index].view:OnShow(this)
|
|
|
|
|
if index == 1 then
|
|
|
|
|
this.titleText.text = "日常任务"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.titleText.text = "成就任务"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:OnClose()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:OnClose()
|
|
|
|
|
end
|
|
|
|
|
ClearRedPointObject(RedPointType.DailyTask)
|
|
|
|
|
ClearRedPointObject(RedPointType.Achievement_Main)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function MissionDailyPanel:OnDestroy()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #contentScripts do
|
|
|
|
|
contentScripts[i].view:OnDestroy()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return MissionDailyPanel
|