109 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			109 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Lua
		
	
require("Base/BasePanel")
 | 
						|
local FightLevelSingleLevelInfoPopup = Inherit(BasePanel)
 | 
						|
local this = FightLevelSingleLevelInfoPopup
 | 
						|
--子模块脚本
 | 
						|
local contentScripts = {
 | 
						|
    --主 副 关卡回放
 | 
						|
    [1] = {view = require("Modules/FightLevel/View/FightLevelInfoPopup_MainLevelBackBattle"), panelName = "FightLevelInfoPopup_MainLevelBackBattle",type=FIGHTLEVEL_POPUP_TYPE.BackBattle},
 | 
						|
    --主关卡详情
 | 
						|
    [2] = {view = require("Modules/FightLevel/View/FightLevelInfoPopup_MainLevel"), panelName = "FightLevelInfoPopup_MainLevel",type=FIGHTLEVEL_POPUP_TYPE.MainLevel},
 | 
						|
    --主关卡奖励
 | 
						|
    [3] = {view = require("Modules/FightLevel/View/FightLevelInfoPopup_MainLevelReward"),panelName="FightLevelInfoPopup_MainLevelReward",type=FIGHTLEVEL_POPUP_TYPE.MainLevelReward},
 | 
						|
    --副关卡详情
 | 
						|
    [4] = {view = require("Modules/FightLevel/View/FightLevelInfoPopup_AssistantLevel"),panelName="FightLevelInfoPopup_AssistantLevel",type=FIGHTLEVEL_POPUP_TYPE.AssistantLevel},
 | 
						|
}
 | 
						|
--子模块预设
 | 
						|
local contentPrefabs={}
 | 
						|
--打开弹窗索引
 | 
						|
local index=0
 | 
						|
 | 
						|
 | 
						|
--初始化组件(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:InitComponent()
 | 
						|
    this.contents=Util.GetGameObject(this.gameObject,"Contents")
 | 
						|
    this.BGImage1=Util.GetGameObject(this.gameObject,"Contents/BG/BGImage1")
 | 
						|
    this.BGImage2=Util.GetGameObject(this.gameObject,"Contents/BG/BGImage2")
 | 
						|
    --this.backBtn=Util.GetGameObject(this.contents,"BackBtn")
 | 
						|
    --子模块脚本初始化
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:InitComponent(Util.GetGameObject(this.contents, contentScripts[i].panelName))
 | 
						|
    end
 | 
						|
    --预设赋值
 | 
						|
    for i=1,#contentScripts do
 | 
						|
        contentPrefabs[i]=Util.GetGameObject(this.contents,contentScripts[i].panelName)
 | 
						|
    end
 | 
						|
 | 
						|
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--绑定事件(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:BindEvent()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:BindEvent()
 | 
						|
    end
 | 
						|
    --返回按钮
 | 
						|
    --Util.AddClick(this.backBtn,function()
 | 
						|
    --    self:ClosePanel()
 | 
						|
    --end)
 | 
						|
end
 | 
						|
 | 
						|
--添加事件监听(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:AddListener()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:AddListener()
 | 
						|
    end
 | 
						|
end
 | 
						|
--移除事件监听(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:RemoveListener()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:RemoveListener()
 | 
						|
    end
 | 
						|
end
 | 
						|
--界面打开时调用(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup: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
 | 
						|
    this.BGImage1:SetActive(index == 1 )
 | 
						|
    this.BGImage2:SetActive(index == 2 or index == 3 or index == 4)
 | 
						|
    contentPrefabs[index].gameObject:SetActive(true)
 | 
						|
    contentScripts[index].view:OnShow(this,...)--1、传入自己 2、传入不定参
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
 | 
						|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:OnShow()
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
function FightLevelSingleLevelInfoPopup:OnSortingOrderChange()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:OnSortingOrderChange(self.sortingOrder)
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--界面关闭时调用(用于子类重写)
 | 
						|
function FightLevelSingleLevelInfoPopup:OnClose()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:OnClose()
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
function FightLevelSingleLevelInfoPopup:OnDestroy()
 | 
						|
    for i = 1, #contentScripts do
 | 
						|
        contentScripts[i].view:OnDestroy()
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
return FightLevelSingleLevelInfoPopup |