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

144 lines
6.3 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)
2021-12-23 17:23:02 +08:00
self.Bg = Util.GetGameObject(self.gameObject,"Bg")
2021-12-22 12:07:00 +08:00
self.mapList = {}
self.mapPre = Util.GetGameObject(self.gameObject,"Map/mapPre")
self.mapParent = Util.GetGameObject(self.gameObject, "Map")
2021-12-23 17:23:02 +08:00
self.backBtn = Util.GetGameObject(self.gameObject, "btns/backBtn")
self.oneKeyExploreBtn = Util.GetGameObject(self.gameObject, "btns/oneKeyExploreBtn")
self.formationBtn = Util.GetGameObject(self.gameObject, "btns/formationBtn")
self.tip = Util.GetGameObject(self.gameObject, "btns/tip")
2021-12-22 12:07:00 +08:00
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()
2021-12-23 17:23:02 +08:00
ForceRebuildLayout(self.Bg.transform)
2021-12-22 12:07:00 +08:00
self.data = ExploreManager.ExploreMapData
self.tip.gameObject:SetActive(false)
2021-12-23 17:23:02 +08:00
self.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
2021-12-22 12:07:00 +08:00
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")
2021-12-23 17:23:02 +08:00
self.mapList[k].bgName = Util.GetGameObject(self.mapList[k].mapInfo,"info/bgName")
self.mapList[k].lock = Util.GetGameObject(self.mapList[k].mapInfo,"info/bgName/Lock")
self.mapList[k].lock.gameObject:SetActive(false)
self.mapList[k].canGetImg = Util.GetGameObject(self.mapList[k].mapInfo,"info/bgName/canGetImg"):GetComponent("Image")
self.mapList[k].canGetImg.gameObject:SetActive(true)
self.mapList[k].nameMask = Util.GetGameObject(self.mapList[k].mapInfo,"info/nameMask"):GetComponent("Text")
self.mapList[k].name = Util.GetGameObject(self.mapList[k].mapInfo,"info/nameMask/name"):GetComponent("Text")
self.mapList[k].exploreIma = Util.GetGameObject(self.mapList[k].mapInfo,"info/exploreIma")
2021-12-22 12:07:00 +08:00
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
2021-12-23 17:23:02 +08:00
self.mapList[k].data = v
self.mapList[k].go.gameObject:SetActive(true)
self.mapList[k].go.transform.localPosition = v.pos
2021-12-22 12:07:00 +08:00
self.mapList[k].mapBgIma.sprite = self.spLoader:LoadSprite(v.iconName)
2021-12-23 17:23:02 +08:00
self.mapList[k].mapBgIma:SetNativeSize()
self.mapList[k].force.text = PrintWanNum4(v.force)
2021-12-22 12:07:00 +08:00
if PlayerManager.level < v.openLevel then
2021-12-23 17:23:02 +08:00
self.mapList[k].condition.gameObject:SetActive(true)
self.mapList[k].conditionTip.text = v.openLevel.."级解锁"
Util.SetGray(self.mapList[k].bgName,true)
2021-12-22 12:07:00 +08:00
else
2021-12-23 17:23:02 +08:00
self.mapList[k].condition.gameObject:SetActive(false)
Util.SetGray(self.mapList[k].bgName,false)
2021-12-22 12:07:00 +08:00
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
2021-12-23 17:23:02 +08:00
self:SetTip(v.pos)
2021-12-22 12:07:00 +08:00
end
end)
end
end
function ExploreMainPanel:SetMapState()
2021-12-23 17:23:02 +08:00
for k,v in pairs(self.mapList) do
v.exploreIma.gameObject:SetActive(LengthOfTable(v.data.formations) > 0)
end
2021-12-22 12:07:00 +08:00
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