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

132 lines
5.6 KiB
Lua
Raw Normal View History

2021-12-22 12:07:00 +08:00
require("Base/BasePanel")
ExploreMainPanel = Inherit(BasePanel)
--初始化组件(用于子类重写)
function ExploreMainPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.upView = SubUIManager.Open(SubUIConfig.UpView,self.gameObject.transform)
self.mapList = {}
self.mapPre = Util.GetGameObject(self.gameObject,"Map/mapPre")
self.mapParent = Util.GetGameObject(self.gameObject, "Map")
self.backBtn = Util.GetGameObject(self.gameObject, "Map/btns/backBtn")
self.oneKeyExploreBtn = Util.GetGameObject(self.gameObject, "Map/btns/oneKeyExploreBtn")
self.formationBtn = Util.GetGameObject(self.gameObject, "Map/btns/formationBtn")
self.tip = Util.GetGameObject(self.gameObject, "Map/tip")
self.xiangqingBtn = Util.GetGameObject(self.tip, "xiangqingBtn")
self.jinruBtn = Util.GetGameObject(self.tip, "jinruBtn")
self.tansuoBtn = Util.GetGameObject(self.tip, "tansuoBtn")
self.mapId = 0
end
--绑定事件(用于子类重写)
function ExploreMainPanel:BindEvent()
Util.AddClick(self.backBtn,function()
self:ClosePanel()
end)
Util.AddClick(self.oneKeyExploreBtn,function()
--一键探索弹窗
2021-12-23 13:09:34 +08:00
UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.OneKeyExplore,ExploreManager.GetFormationData(0),ExploreManager.GetMapsData())
2021-12-22 12:07:00 +08:00
end)
Util.AddClick(self.formationBtn,function()
--探索队伍弹窗
2021-12-23 13:09:34 +08:00
--0 调整 1探索
UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.ExploreSelectFormation,ExploreManager.GetFormationData(1),0,ExploreManager.ExploreMapData[self.mapId])
2021-12-22 12:07:00 +08:00
end)
Util.AddClick(self.xiangqingBtn,function()
--地图详情tips
UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.ExploreMapTip,ExploreManager.GetExploreMapTipData(self.mapId))
end)
Util.AddClick(self.jinruBtn,function()
2021-12-23 13:09:34 +08:00
UIManager.OpenPanel(UIName.ExplorePanel,ExploreManager.ExploreMapData[self.mapId])
2021-12-22 12:07:00 +08:00
end)
Util.AddClick(self.tansuoBtn,function()
--选择队伍弹窗
2021-12-23 13:09:34 +08:00
UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.ExploreSelectFormation,ExploreManager.GetFormationData(0),1,ExploreManager.ExploreMapData[self.mapId])
2021-12-22 12:07:00 +08:00
end)
end
--添加事件监听(用于子类重写)
function ExploreMainPanel:AddListener()
end
--移除事件监听(用于子类重写)
function ExploreMainPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExploreMainPanel:OnOpen()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExploreMainPanel:OnShow()
self.data = ExploreManager.ExploreMapData
self.tip.gameObject:SetActive(false)
self:SetMapData()
self:SetMapState()
end
function ExploreMainPanel:SetMapData()
for k,v in pairs(self.mapList) do
v.go.gameObject:SetActive(false)
end
for k,v in pairs(self.data) do
if not self.mapList[k] then
self.mapList[k] = {}
self.mapList[k].go = newObjToParent(self.mapPre,self.mapParent)
self.mapList[k].mapBg = Util.GetGameObject(self.mapList[k].go,"mapBg")
self.mapList[k].mapBgIma = Util.GetGameObject(self.mapList[k].mapBg,"ImgBg"):GetComponent("Image")
self.mapList[k].mapInfo = Util.GetGameObject(self.mapList[k].go,"mapInfo")
self.mapList[k].force = Util.GetGameObject(self.mapList[k].mapInfo,"minForce/Text"):GetComponent("Text")
self.mapList[k].lock = Util.GetGameObject(self.mapList[k].mapInfo,"name/Lock")
self.mapList[k].canGetImg = Util.GetGameObject(self.mapList[k].mapInfo,"name/canGetImg"):GetComponent("Image")
self.mapList[k].nameMask = Util.GetGameObject(self.mapList[k].mapInfo,"name/nameMask"):GetComponent("Text")
self.mapList[k].name = Util.GetGameObject(self.mapList[k].mapInfo,"name/name"):GetComponent("Text")
self.mapList[k].exploreIma = Util.GetGameObject(self.mapList[k].mapInfo,"name/exploreIma")
self.mapList[k].condition = Util.GetGameObject(self.mapList[k].mapInfo,"condition")
self.mapList[k].conditionTip = Util.GetGameObject(self.mapList[k].condition,"Text"):GetComponent("Text")
end
self.mapList[k].go.gameObject:SetActive(false)
self.mapList[k].mapBgIma.sprite = self.spLoader:LoadSprite(v.iconName)
self.mapList[k].force.text = v.force
if PlayerManager.level < v.openLevel then
self.mapList[k].lock.gameObject:SetActive(true)
self.mapList[k].canGetImg.gameObject:SetActive(false)
else
self.mapList[k].lock.gameObject:SetActive(false)
self.mapList[k].canGetImg.gameObject:SetActive(false)
end
self.mapList[k].canGetImg.sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(v.mainRewardId))
self.mapList[k].nameMask.text = v.name
self.mapList[k].name.text = v.name
Util.AddOnceClick(self.mapList[k].go,function()
if PlayerManager.level >= v.openLevel then
self.mapId = k
self:SetTip(self.mapList[k].go.transform.localPosition)
end
end)
end
end
function ExploreMainPanel:SetMapState()
end
function ExploreMainPanel:SetTip(pos)
self.tip.gameObject:SetActive(true)
self.tip.transform.localPosition = pos
end
--界面关闭时调用(用于子类重写)
function ExploreMainPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ExploreMainPanel:OnDestroy()
self.mapList = {}
2021-12-23 13:09:34 +08:00
SubUIManager.Close(self.upView)
self.upView = nil
self.spLoader:Destroy()
2021-12-22 12:07:00 +08:00
end
return ExploreMainPanel