miduo_client/Assets/ManagedResources/~Lua/Modules/Mission/MissionDailyPanel.lua

200 lines
7.8 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
MissionDailyPanel = Inherit(BasePanel)
local this = MissionDailyPanel
2020-06-03 19:09:01 +08:00
--子模块脚本
local contentScripts = {
--日常
2020-08-19 10:05:01 +08:00
[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} ,
2020-06-03 19:09:01 +08:00
--成就
2020-08-19 10:05:01 +08:00
[4] = {view = require("Modules/Mission/MissionDailyPanel_Achievement"), panelName = "MissionDailyPanel_Achievement",type=4},
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 = "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),
2020-06-03 19:09:01 +08:00
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
--子模块预设
local contentPrefabs={}
--打开弹窗索引
local index=0
2020-08-26 15:57:06 +08:00
local type = 0 --0 日常 1青龙
2020-06-03 19:09:01 +08:00
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.mask = Util.GetGameObject(self.transform, "mask")
2020-06-03 19:09:01 +08:00
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))
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
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)
Util.AddClick(this.mask, function()
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,...)
--根据传入类型打开对应面板
2020-06-13 11:47:13 +08:00
index = popupType
2020-08-26 15:57:06 +08:00
local temp = {...}
if temp and temp[1] then
type = temp[1]
else
type = 0
end
2020-06-13 11:47:13 +08:00
if not index then
index = 1
2020-08-26 18:29:27 +08:00
type = 0
2020-07-01 09:40:20 +08:00
if RedPointManager.GetRedPointMissionDaily() then
index = 1
2020-08-26 15:57:06 +08:00
type = 0
2020-09-22 11:58:49 +08:00
elseif ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) and ActivityGiftManager.IsQualifiled( ActivityTypeDef.TreasureOfSomeBody) then
2020-08-26 18:29:27 +08:00
if QinglongSerectTreasureManager.GetQinglongSerectTreasureRedPot() then
index = 2
type = 1
elseif QinglongSerectTreasureManager.GetSerectTreasureTrailRedPot() then
index = 3
type = 1
end
2020-08-19 10:05:01 +08:00
elseif TaskManager.GetAchievementState() then
index = 4
2020-08-26 15:57:06 +08:00
type = 0
2020-06-13 11:47:13 +08:00
end
end
2020-06-03 19:09:01 +08:00
for i=1,#contentPrefabs do
contentPrefabs[i].gameObject:SetActive(false)
end
2020-08-26 15:57:06 +08:00
if index ~=1 and type == 0 then
2020-08-26 18:29:27 +08:00
index = 4
2020-08-26 15:57:06 +08:00
end
2020-06-03 19:09:01 +08:00
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-08-19 10:05:01 +08:00
if redPointList[1] and redPointList[2] and redPointList[3] and redPointList[4] then
2020-06-03 19:09:01 +08:00
BindRedPointObject(RedPointType.DailyTask, redPointList[1])
2020-08-19 10:05:01 +08:00
BindRedPointObject(RedPointType.QinglongSerectTreasure, redPointList[2])
BindRedPointObject(RedPointType.QinglongSerectTreasureTrail, redPointList[3])
BindRedPointObject(RedPointType.Achievement_Main, redPointList[4])
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
2020-06-08 20:18:49 +08:00
contentScripts[i].view:OnSortingOrderChange(self.sortingOrder)
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")
2021-04-21 13:12:04 +08:00
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
Util.GetGameObject(tab,"Image"):GetComponent("Image"):SetNativeSize()
2020-06-03 19:09:01 +08:00
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
2020-10-01 00:05:54 +08:00
if _TabData[index].type ~= -1 then
2020-09-22 11:58:49 +08:00
if ActivityGiftManager.IsQualifiled( _TabData[index].type) and ActivityGiftManager.GetActivityOpenStatus( _TabData[index].type) then
2020-10-01 00:05:54 +08:00
tab.gameObject:SetActive(true)
else
tab.gameObject:SetActive(false)
end
else
tab.gameObject:SetActive(true)
2020-08-24 14:00:15 +08:00
end
2020-06-03 19:09:01 +08:00
end
--切换视图
function this.SwitchView(_index)
2020-08-19 10:05:01 +08:00
if _index == 2 or _index == 3 then
2020-08-25 16:23:41 +08:00
if not ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.TreasureOfSomeBody) then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10773])
2020-08-19 10:05:01 +08:00
return
end
end
2020-06-03 19:09:01 +08:00
--先执行上一面板关闭逻辑
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
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11315]
2020-08-19 10:05:01 +08:00
elseif index == 2 then
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11316]
2020-08-19 10:05:01 +08:00
elseif index == 3 then
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11317]
2020-08-19 10:05:01 +08:00
elseif index == 4 then
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11319]
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-08-19 10:05:01 +08:00
ClearRedPointObject(RedPointType.QinglongSerectTreasure)
ClearRedPointObject(RedPointType.QinglongSerectTreasureTrail)
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()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
end
2020-06-03 19:09:01 +08:00
2020-06-23 18:36:24 +08:00
return MissionDailyPanel