miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/ExpeditionMonsterInfoPopup.lua

105 lines
3.3 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local ExpeditionMonsterInfoPopup = Inherit(BasePanel)
2020-05-25 19:16:23 +08:00
local this = ExpeditionMonsterInfoPopup
--子模块脚本
local contentScripts = {
--招募
[1] = {view = require("Modules/Expedition/View/ExpeditionMonsterInfo_Recruit"), panelName = "ExpeditionMonsterInfo_Recruit",type=EXPEDITON_POPUP_TYPE.Recruit},
--商店
[2] = {view = require("Modules/Expedition/View/ExpeditionMonsterInfo_Shop"), panelName = "ExpeditionMonsterInfo_Shop",type=EXPEDITON_POPUP_TYPE.Shop},
-- 普通 精英 boss 贪婪
[3]= {view=require("Modules/Expedition/View/ExpeditionMonsterInfo_Monster"),panelName="ExpeditionMonsterInfo_Monster",type=EXPEDITON_POPUP_TYPE.Monster},
--试炼
[4]= {view=require("Modules/Expedition/View/ExpeditionMonsterInfo_Trail"),panelName="ExpeditionMonsterInfo_Trail",type=EXPEDITON_POPUP_TYPE.Trail},
--贪婪
[5]= {view=require("Modules/Expedition/View/ExpeditionMonsterInfo_Greed"),panelName="ExpeditionMonsterInfo_Greed",type=EXPEDITON_POPUP_TYPE.Greed},
}
--子模块预设
local contentPrefabs={}
--打开弹窗索引
local index=0
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function ExpeditionMonsterInfoPopup:InitComponent()
2020-05-25 19:16:23 +08:00
this.contents=Util.GetGameObject(this.gameObject,"Contents")
--this.backBtn=Util.GetGameObject(this.contents,"BackBtn")
--子模块脚本初始化
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-05-25 19:16:23 +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
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function ExpeditionMonsterInfoPopup:BindEvent()
2020-05-25 19:16:23 +08:00
for i = 1, #contentScripts do
contentScripts[i].view:BindEvent()
end
--返回按钮
--Util.AddClick(this.backBtn,function()
-- self:ClosePanel()
--end)
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function ExpeditionMonsterInfoPopup:AddListener()
2020-05-25 19:16:23 +08:00
for i = 1, #contentScripts do
contentScripts[i].view:AddListener()
end
2020-05-09 13:31:21 +08:00
end
--移除事件监听(用于子类重写)
function ExpeditionMonsterInfoPopup:RemoveListener()
2020-05-25 19:16:23 +08:00
for i = 1, #contentScripts do
contentScripts[i].view:RemoveListener()
end
2020-05-09 13:31:21 +08:00
end
--界面打开时调用(用于子类重写)
2020-05-25 19:16:23 +08:00
function ExpeditionMonsterInfoPopup:OnOpen(popupType,...)
-- local args={...}
-- popupType=args[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
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExpeditionMonsterInfoPopup:OnShow()
end
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
--界面关闭时调用(用于子类重写)
2020-05-25 19:16:23 +08:00
function ExpeditionMonsterInfoPopup:OnClose()for i = 1, #contentScripts do
contentScripts[i].view:OnClose()
end
2020-05-09 13:31:21 +08:00
end
function ExpeditionMonsterInfoPopup:OnDestroy()
2020-05-25 19:16:23 +08:00
for i = 1, #contentScripts do
contentScripts[i].view:OnDestroy()
end
2020-05-09 13:31:21 +08:00
end
return ExpeditionMonsterInfoPopup