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

68 lines
2.1 KiB
Lua
Raw Normal View History

2021-12-22 12:07:00 +08:00
require("Base/BasePanel")
ExplorePanel = Inherit(BasePanel)
2021-12-24 00:33:33 +08:00
local this = ExplorePanel
2021-12-23 17:23:02 +08:00
-- 小地图
local fightMap = require("Modules/Fight/View/ExploreMapView")
2021-12-22 12:07:00 +08:00
--初始化组件(用于子类重写)
function ExplorePanel:InitComponent()
2021-12-24 14:09:48 +08:00
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")
2021-12-23 17:23:02 +08:00
2021-12-24 14:09:48 +08:00
fightMap:InitComponent(this.gameObject, this)
2021-12-22 12:07:00 +08:00
end
2021-12-24 00:33:33 +08:00
--绑定事件(用于子类重写
2021-12-22 12:07:00 +08:00
function ExplorePanel:BindEvent()
2021-12-24 14:09:48 +08:00
Util.AddClick(this.backBtn,function()
2021-12-30 11:55:15 +08:00
SwitchPanel.ClosePanel(UIName.ExplorePanel, function()end)
2021-12-23 13:09:34 +08:00
end)
2021-12-24 14:09:48 +08:00
Util.AddClick(this.lookReward,function()
UIManager.OpenPanel(UIName.ExploreRewardPopup,this.mapData.mapId)
2021-12-23 13:09:34 +08:00
end)
2021-12-22 12:07:00 +08:00
end
2021-12-28 17:52:28 +08:00
--添加事件监听(用于子类重写)
2021-12-22 12:07:00 +08:00
function ExplorePanel:AddListener()
2021-12-28 17:52:28 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Explore.UpdateFormation,this.OnShow)
2021-12-29 16:05:16 +08:00
fightMap:AddListener()
2021-12-22 12:07:00 +08:00
end
--移除事件监听(用于子类重写)
function ExplorePanel:RemoveListener()
2021-12-28 17:52:28 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Explore.UpdateFormation,this.OnShow)
2021-12-22 12:07:00 +08:00
end
--界面打开时调用(用于子类重写)
2021-12-23 13:09:34 +08:00
function ExplorePanel:OnOpen(data)
2021-12-24 14:09:48 +08:00
this.mapData = data
2021-12-28 17:52:28 +08:00
fightMap:Init()
2021-12-22 12:07:00 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
2021-12-30 11:41:13 +08:00
function ExplorePanel:OnShow()
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ExploreFun })
2021-12-28 17:52:28 +08:00
this.data = ExploreManager.GetFormationDataByMapId(this.mapData.mapId)
if not this.data or #this.data < 1 then
2021-12-30 11:55:15 +08:00
SwitchPanel.ClosePanel(UIName.ExplorePanel, function()end)
2021-12-28 17:52:28 +08:00
end
2021-12-22 12:07:00 +08:00
end
--界面关闭时调用(用于子类重写)
function ExplorePanel:OnClose()
2021-12-24 14:09:48 +08:00
fightMap:OnClose()
2021-12-23 17:23:02 +08:00
end
2021-12-28 17:52:28 +08:00
2021-12-23 17:23:02 +08:00
function ExplorePanel:OnSortingOrderChange()
2021-12-24 14:09:48 +08:00
fightMap:OnSortingOrderChange(this.sortingOrder)
2021-12-22 12:07:00 +08:00
end
2021-12-28 17:52:28 +08:00
2021-12-22 12:07:00 +08:00
--界面销毁时调用(用于子类重写)
function ExplorePanel:OnDestroy()
2021-12-24 14:09:48 +08:00
SubUIManager.Close(this.upView)
this.upView = nil
this.spLoader:Destroy()
2021-12-22 12:07:00 +08:00
end
return ExplorePanel