miduo_client/Assets/ManagedResources/~Lua/Modules/Explore/ExplorePanel.lua

68 lines
2.1 KiB
Lua

require("Base/BasePanel")
ExplorePanel = Inherit(BasePanel)
local this = ExplorePanel
-- 小地图
local fightMap = require("Modules/Fight/View/ExploreMapView")
--初始化组件(用于子类重写)
function ExplorePanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.upView = SubUIManager.Open(SubUIConfig.UpView,this.gameObject.transform)
this.backBtn = Util.GetGameObject(this.gameObject, "btns/backBtn")
this.lookReward = Util.GetGameObject(this.gameObject, "btns/lookReward")
fightMap:InitComponent(this.gameObject, this)
end
--绑定事件(用于子类重写
function ExplorePanel:BindEvent()
Util.AddClick(this.backBtn,function()
SwitchPanel.ClosePanel(UIName.ExplorePanel, function()end)
end)
Util.AddClick(this.lookReward,function()
UIManager.OpenPanel(UIName.ExploreRewardPopup,this.mapData.mapId)
end)
end
--添加事件监听(用于子类重写)
function ExplorePanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Explore.UpdateFormation,this.OnShow)
fightMap:AddListener()
end
--移除事件监听(用于子类重写)
function ExplorePanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Explore.UpdateFormation,this.OnShow)
end
--界面打开时调用(用于子类重写)
function ExplorePanel:OnOpen(data)
this.mapData = data
fightMap:Init()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExplorePanel:OnShow()
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ExploreFun })
this.data = ExploreManager.GetFormationDataByMapId(this.mapData.mapId)
if not this.data or #this.data < 1 then
SwitchPanel.ClosePanel(UIName.ExplorePanel, function()end)
end
end
--界面关闭时调用(用于子类重写)
function ExplorePanel:OnClose()
fightMap:OnClose()
end
function ExplorePanel:OnSortingOrderChange()
fightMap:OnSortingOrderChange(this.sortingOrder)
end
--界面销毁时调用(用于子类重写)
function ExplorePanel:OnDestroy()
SubUIManager.Close(this.upView)
this.upView = nil
this.spLoader:Destroy()
end
return ExplorePanel