require("Base/BasePanel") ExploreMainPanel = Inherit(BasePanel) --初始化组件(用于子类重写) function ExploreMainPanel:InitComponent() self.spLoader = SpriteLoader.New() self.upView = SubUIManager.Open(SubUIConfig.UpView,self.gameObject.transform) self.Bg = Util.GetGameObject(self.gameObject,"Bg") self.mapList = {} self.mapPre = Util.GetGameObject(self.gameObject,"Map/mapPre") self.mapParent = Util.GetGameObject(self.gameObject, "Map") 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") 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() --一键探索弹窗 UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.OneKeyExplore,ExploreManager.GetFormationData(0),ExploreManager.GetMapsData()) end) Util.AddClick(self.formationBtn,function() --探索队伍弹窗 --0 调整 1探索 UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.ExploreSelectFormation,ExploreManager.GetFormationData(1),0,ExploreManager.ExploreMapData[self.mapId]) end) Util.AddClick(self.xiangqingBtn,function() --地图详情tips UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.ExploreMapTip,ExploreManager.GetExploreMapTipData(self.mapId)) end) Util.AddClick(self.jinruBtn,function() UIManager.OpenPanel(UIName.ExplorePanel,ExploreManager.ExploreMapData[self.mapId]) end) Util.AddClick(self.tansuoBtn,function() --选择队伍弹窗 UIManager.OpenPanel(UIName.GeneralSizeFitterPopup,GENERALSIZEFITTER_TYPE.ExploreSelectFormation,ExploreManager.GetFormationData(0),1,ExploreManager.ExploreMapData[self.mapId]) end) end --添加事件监听(用于子类重写) function ExploreMainPanel:AddListener() end --移除事件监听(用于子类重写) function ExploreMainPanel:RemoveListener() end --界面打开时调用(用于子类重写) function ExploreMainPanel:OnOpen() end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function ExploreMainPanel:OnShow() ForceRebuildLayout(self.Bg.transform) self.data = ExploreManager.ExploreMapData self.tip.gameObject:SetActive(false) self.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) 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].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") 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].data = v self.mapList[k].go.gameObject:SetActive(true) self.mapList[k].go.transform.localPosition = v.pos self.mapList[k].mapBgIma.sprite = self.spLoader:LoadSprite(v.iconName) self.mapList[k].mapBgIma:SetNativeSize() self.mapList[k].force.text = PrintWanNum4(v.force) if PlayerManager.level < v.openLevel then self.mapList[k].condition.gameObject:SetActive(true) self.mapList[k].conditionTip.text = v.openLevel.."级解锁" Util.SetGray(self.mapList[k].bgName,true) else self.mapList[k].condition.gameObject:SetActive(false) Util.SetGray(self.mapList[k].bgName,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(v.pos) end end) end end function ExploreMainPanel:SetMapState() for k,v in pairs(self.mapList) do v.exploreIma.gameObject:SetActive(LengthOfTable(v.data.formations) > 0) end 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 = {} SubUIManager.Close(self.upView) self.upView = nil self.spLoader:Destroy() end return ExploreMainPanel