require("Base/BasePanel") require("Modules/Map/Logic/TileMapController") require("Modules/Map/Logic/TileMapView") require("Modules/Map/View/MapPointView") MapPanel = Inherit(BasePanel) local this = MapPanel local ChallengeMapConfig = ConfigManager.GetConfig(ConfigName.ChallengeMapConfig) local DifficultyData = ConfigManager.GetConfig(ConfigName.ChallengeConfig) local missionView = require("Modules/Map/View/MapMissionView") local ctrlView = require("Modules/Map/View/MapControllView") local playerView = require("Modules/Map/View/MapPlayerView") local trialPanel = require("Modules/Map/TrialMapPanel") local eliteMissionView = require("Modules/Map/View/CarbonMissionTypeView") local endLessMapView = require("Modules/Map/View/EndLessMapView") local pointHandleView = require("Modules/Map/View/PointHandleView") local _PropItemList = {} local _PointerDownList = {} local _PointerUpList = {} --初始化组件(用于子类重写) function this:InitComponent() -- 通用图标 -- this.BtnBack = Util.GetGameObject(self.gameObject, "rightUp/btnBack") this.BtnBack = Util.GetGameObject(self.gameObject, "centerDown/bg/btnBack") this.btnAchive = Util.GetGameObject(self.gameObject, "rightDown/btnAchive") this.btnBag = Util.GetGameObject(self.gameObject, "rightUp/btnBag") this.btnTeam = Util.GetGameObject(self.gameObject, "rightUp/btnTeam") this.btnSetting = Util.GetGameObject(self.gameObject, "rightUp/btnSetting") this.btnRank = Util.GetGameObject(self.gameObject, "leftCenter/btnRank") this.btnXingYao=Util.GetGameObject(self.gameObject,"rightDown/btnXingYao") this.xingYaoNum=Util.GetGameObject(this.btnXingYao,"num"):GetComponent("Text") this.btnReward=Util.GetGameObject(self.gameObject,"leftCenter/btnReward") this.item = Util.GetGameObject(self.gameObject, "item") -- 显示死亡计时时间 -- this.deadRoot = Util.GetGameObject(self.gameObject, "RevivePanel") -- this.deadTime = Util.GetGameObject(self.gameObject, "RevivePanel/bg/Time"):GetComponent("Text") -- buff显示 this.propList = Util.GetGameObject(self.transform, "centerDown/bufflist") this.propBox = Util.GetGameObject(this.propList, "box") this.propItem = Util.GetGameObject(this.propBox, "buff") this.propInfo = Util.GetGameObject(this.propList, "info") this.propContent = Util.GetGameObject(this.propList, "info/Text"):GetComponent("Text") this.propInfo:SetActive(false) this.propList:SetActive(true) -- 行动力警告显示 this.warn = Util.GetGameObject(self.gameObject, "EndLessEffect/effect") this.warnRoot = Util.GetGameObject(self.gameObject, "EndLessEffect") -- 面板遮罩, 没有接地图任务前不可点击 this.Mask = Util.GetGameObject(self.gameObject, "Mask") -- 试炼副本相关组件 this.leftUp = Util.GetGameObject(self.gameObject, "leftUp") this.centerDonwn = Util.GetGameObject(self.gameObject, "centerDown") missionView.InitComponent(self.gameObject, this) playerView.InitComponent(self.gameObject, this) ctrlView.InitComponent(self.gameObject, this, playerView) trialPanel:InitComponent(self.gameObject, this) endLessMapView.InitComponent(self.gameObject, this) end function this:OnSortingOrderChange() trialPanel.OnSortingOrderChange() endLessMapView.OnSortingOrderChange() end --绑定事件(用于子类重写) function this:BindEvent() Util.AddClick(this.BtnBack, function () if ctrlView.GetCallListCount() > 1 then PopupTipPanel.ShowTip(Language[11232]) return end this.SetEliteBackShow() this.SetEndlessShow() end) -- Util.AddClick(this.BtnBack2, function () -- if ctrlView.GetCallListCount() > 1 then -- PopupTipPanel.ShowTip(Language[11232]) -- return -- end -- this.SetEliteBackShow() -- this.SetEndlessShow() -- end) -- 功绩按钮 Util.AddClick(this.btnAchive, function () UIManager.OpenPanel(UIName.EliteCarbonAchievePanel, MapManager.GetCurCarbonId(), false, 1) end) --排行 Util.AddClick(this.btnRank, function () UIManager.OpenPanel(UIName.CarbonScoreSortPanel,1) end) --回春散 Util.AddClick(this.btnXingYao,function() UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialXingYao) end) --奖励 Util.AddClick(this.btnReward,function() UIManager.OpenPanel(UIName.TrialRewardPopup) end) missionView.BindEvent() trialPanel:BindEvent() endLessMapView.BindEvent() end -- ================ 点击回城时一些稀里糊涂的操作 ====== -- 精英副本 function this.SetEliteBackShow() if CarbonManager.difficulty == 3 then eliteMissionView:OnBackBtnClick() end end -- 无尽副本 function this.SetEndlessShow() -- 无尽副本的回城设置 if CarbonManager.difficulty == 4 then -- 先看看是否是能回去 if not EndLessMapManager.IsMapTeamAlive()then PopupTipPanel.ShowTip(Language[11233]) return end -- 先发更新事件点协议 MapManager.MapUpdateEvent(-1000, function () Log(Language[11234]) NetManager.RequestEndLessStats(function () UIManager.OpenPanel(UIName.MapStatsPanel, true) end) end) else Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out, 1, 0) end end -- =============================================== --添加事件监听(用于子类重写) function this:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Map.Out, this.OnMapOut) Game.GlobalEvent:AddEvent(GameEvent.Map.DeadOut, this.OnMapDeadOut) Game.GlobalEvent:AddEvent(GameEvent.Map.MapDataChange, this.OnMapDataChange) Game.GlobalEvent:AddEvent(GameEvent.Map.StopWalk, this.StopWalking) Game.GlobalEvent:AddEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.RefreshBuffShow) missionView.AddListener() playerView.AddListener() ctrlView.AddListener() trialPanel:AddListener() endLessMapView.AddListener() pointHandleView.AddListener() end --移除事件监听(用于子类重写) function this:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Map.Out, this.OnMapOut) Game.GlobalEvent:RemoveEvent(GameEvent.Map.DeadOut, this.OnMapDeadOut) Game.GlobalEvent:RemoveEvent(GameEvent.Map.MapDataChange, this.OnMapDataChange) Game.GlobalEvent:RemoveEvent(GameEvent.Map.StopWalk, this.StopWalking) Game.GlobalEvent:RemoveEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.RefreshBuffShow) missionView.RemoveListener() playerView.RemoveListener() ctrlView.RemoveListener() trialPanel:RemoveListener() endLessMapView.RemoveListener() pointHandleView.RemoveListener() end function this:OnShow() UIManager.camera.clearFlags = CameraClearFlags.Depth local mapId = MapManager.curMapId --- 副本地图音效统一改成一个 SoundManager.PlayMusic(SoundConfig.BGM_CarbonMap) -- 环境音 local amb = ChallengeMapConfig[mapId].EnvironmentSound if amb and amb ~= "" then SoundManager.PlayAmbient(amb) end this.xingYaoNum.text = BagManager.GetItemCountById(31) playerView.OnShow() endLessMapView.OnShow() pointHandleView.OnShow() trialPanel:OnShow() end --界面打开时调用(用于子类重写) function this:OnOpen(...) Log(Language[11235]) MapManager.FirstEnter = true EndLessMapManager.EndLessRoleDead = true -- 永久隐藏设置按钮 ctrlView.Init() CarbonManager.isPassFight = true -- 在这设置所有副本的初始化设置 -- 根据副本类型显示 this.InitCompShow(CarbonManager.difficulty) -- 地图迷雾显示 this.SetMapFog() pointHandleView.GeneratePoint() -- 进地图初始化位置 local pos = MapManager.roleInitPos this.InitRolePosition(pos, MapManager.curMapId) EndLessMapManager.srcMapId = MapManager.curMapId missionView.Init() trialPanel:OnOpen() endLessMapView.OnOpen() -- 副本相关的初始化设置 this.InitCarbonSet() -- 如果100%,弹出离开界面 this.ExploreInitSet() this.InitrightUpBtn() ---- 刷新被主角狗眼糟蹋过的点 EndLessMapManager.isOpenedFullPanel = false --- 刷新buff显示 this.RefreshBuffShow() end ---==================== 地图初始化处理部分 ================================== function this.SetMapFog() local mapId = MapManager.curMapId local fogVal = ChallengeMapConfig[mapId].isShowFog if fogVal and fogVal == 0 then TileMapView.isShowFog = false else TileMapView.isShowFog = true end end -- 有探索度地图的初始化 function this.ExploreInitSet() --首先他得有探索度 local curMapId = MapManager.curMapId if DifficultyData[curMapId] and DifficultyData[curMapId].IsExplore == 1 then local isPass = CarbonManager.ExplorationDone() if isPass then UIManager.OpenPanel(UIName.MapStatsPanel) end end end function this.InitCarbonSet() -- 死亡表现 -- this.deadRoot:SetActive(false) -- 面板遮罩 this.Mask:SetActive(not MapManager.isOpen) --如果是在序章 local isStartMap = MapManager.curMapId == 100 this.BtnBack:SetActive(not isStartMap) end -- 根据副本的类型显示组件 function this.InitCompShow(type) this.leftUp:SetActive(type == 2) this.centerDonwn:SetActive(true) end -- 角色位置初始化bb function this.InitRolePosition(pos, curMapId) local u, v = Map_Pos2UV(pos) TileMapView.Init() TileMapController.LocateToUV(u, v) local scale = TileMapView.GetMapScale() MapManager.mapScale = scale TileMapController.SetScale(TileMapView.GetMapMinScale()) TileMapView.UpdateFunc() if MapManager.isOpen then this.SetRoleShow(scale, pos) end MapManager.stepList = {} end -- 设置小人落地 function this.SetRoleShow(scale, pos) Log("this.SetRoleShow(scale, pos)") DoTween.To(DG.Tweening.Core.DOGetter_float(function () return TileMapView.GetMapMinScale() end), DG.Tweening.Core.DOSetter_float(TileMapController.SetScale), scale, 1):SetEase(Ease.Linear):OnComplete(function () this.Mask:SetActive(false) playerView.Init(pos) -- 进图初始化完成 MapManager.FirstEnter = false playerView.leader.transform:SetParent(ctrlView.Ctrl.transform) -- leader的父级设置为Ctrl后,Z轴的值发生了变化, 需要重新设置 local v3 = playerView.leader.transform.localPosition playerView.leader.transform.localPosition = Vector3.New(v3.x, v3.y, -10) end) end -- 根据选择的副本类型设置显示的按钮 function this.InitrightUpBtn() this.btnAchive:SetActive(CarbonManager.difficulty == 3) end ---=============================================================================== -- 修改地图的数据时相应的表现 function this.OnMapDataChange(refreshType) if refreshType then if refreshType == 1 then -- 增加地图移动速度 elseif refreshType == 2 then -- 增加视野范围 local u, v = Map_Pos2UV(MapManager.curPos) TileMapView.UpdateWarFog(u, v, MapManager.fogSize) elseif refreshType == 3 then -- 增加扎营次数 elseif refreshType == 4 then --增加采矿暴击率 elseif refreshType == 5 then -- 刷新行动力显示 elseif refreshType == 6 then -- 驱散指定区域的迷雾 else Log(Language[11236]) end end end --界面关闭时调用(用于子类重写) function this:OnClose() playerView.PlayerMove() UIManager.camera.clearFlags = CameraClearFlags.Skybox trialPanel:OnClose() endLessMapView.OnClose() MapTrialManager.firstEnter = false -- 记录界面关闭但是没有注销 EndLessMapManager.isOpenedFullPanel = true SoundManager.PauseAmbient() end -- 刷新buff显示 function this.RefreshBuffShow() -- 关闭所有显示 for _, propItem in pairs(_PropItemList) do propItem:SetActive(false) end -- 重新显示 local props = FoodBuffManager.GetBuffPropList() if not props then return end for index, prop in ipairs(props) do if GetProIndexByProId(prop.id) ~= 2 then local item = _PropItemList[index] if not item then item = newObjToParent(this.propItem, this.propBox) _PropItemList[index] = item end this.BuffItemAdapter(item, prop, index) item:SetActive(true) end end end -- buff显示匹配 function this.BuffItemAdapter(item, prop, index) local icon = Util.GetGameObject(item, "icon"):GetComponent("Image") local stepImg = Util.GetGameObject(item, "stepImg") local leftStep = Util.GetGameObject(item, "stepImg/step"):GetComponent("Text") local propInfo = ConfigManager.GetConfigData(ConfigName.PropertyConfig, prop.id) -- 图标 if propInfo.BuffShow then local lastStr = "" if propInfo.IfBuffShow == 1 then lastStr = prop.value >= 0 and "_Up" or "_Down" end icon.sprite = Util.LoadSprite(propInfo.BuffShow .. lastStr) else Log(Language[11237]..prop.id..Language[11238]) end -- 剩余步数 stepImg:SetActive(prop.step >= 0) leftStep.text = prop.step -- 长按事件监听 local trigger = Util.GetEventTriggerListener(item) --当之前注册过长按监听,则先移除 if _PointerDownList[index] then trigger.onPointerDown = trigger.onPointerDown - _PointerDownList[index] trigger.onPointerUp = trigger.onPointerUp - _PointerUpList[index] end -- 事件监听 _PointerDownList[index] = function(Pointgo, data) -- 显示内容 local val = prop.value local express1 = val >= 0 and "+" or "" local express2 = "" if propInfo.Style == 2 then val = val / 100 express2 = "%" end this.propContent.text = propInfo.Info .. express1..val..express2 -- 显示位置 local pos = item.transform.localPosition this.propInfo.transform.localPosition = Vector3(pos.x, pos.y + 120, 0) this.propInfo:SetActive(true) end _PointerUpList[index] = function(Pointgo, data) this.propInfo:SetActive(false) end trigger.onPointerDown = trigger.onPointerDown + _PointerDownList[index] trigger.onPointerUp = trigger.onPointerUp + _PointerUpList[index] end --界面销毁时调用(用于子类重写) function this:OnDestroy() this.Dispose() trialPanel:OnDestroy() endLessMapView.OnDestroy() _PropItemList = {} _PointerDownList = {} _PointerUpList = {} end function this.PathEnd() ctrlView.ClearCallList() playerView.PlayerIdle() end --刷新动态点的显示 function this.RefreshShow() pointHandleView.leaderMapData = playerView.leaderMapData pointHandleView.RefreshShow() end function this.OnMapOut(nextMapId, outType) Log("outType ====== " .. outType) -- 无尽副本需要传目的地的地图ID local distMapId = 0 if CarbonManager.difficulty == CARBON_TYPE.ENDLESS and nextMapId > 0 then distMapId = nextMapId end NetManager.MapOutRequest(outType, function (msg) if nextMapId == 100 or nextMapId == 0 then this.BackHome() elseif nextMapId == 1 then -- 正常出图 this.BackToCarbonPanel() else --换层或者换地图 this.ChangeMapByType(nextMapId, msg) end Game.GlobalEvent:DispatchEvent(GameEvent.Event.PointTriggerEnd) end, distMapId) end -- ========================= 死出图的各种方法 ========================== -- 序章回到主界面 function this.BackHome() local triggerCallBack triggerCallBack = function (panelType, panel) if panelType == UIName.MapPanel then this.Dispose() Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) end BagManager.InBagGetMapBag() end Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- 清空一下副本任务 MissionManager.carBonMission = {} SwitchPanel.OpenPanel(UIName.MainPanel) poolManager:ClearPool() end -- 正常出图时需要打开的界面类型 local panelNeedOpen = { [1] = UIName.PlotCarbonPanel, [2] = UIName.TrialCarbonPanel, [3] = UIName.EliteCarbonPanel, [4] = UIName.EndLessCarbonPanel, } -- 从副本正常出图 function this.BackToCarbonPanel() local triggerCallBack triggerCallBack = function (panelType, panel) if panelType == UIName.MapPanel then this.Dispose() Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) end BagManager.InBagGetMapBag() end Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- 清空一下副本任务 this.ResetMapData() -- 从序章出来的回到主界面 if MapManager.curMapId == 0 or MapManager.curMapId == 100 then SwitchPanel.OpenPanel(UIName.MainPanel) else if(MapTrialManager.curTowerLevel>MapTrialManager.highestLevel) then if not MapTrialManager.IsFinalLevel()then MapTrialManager.highestLevel=MapTrialManager.curTowerLevel-1 else MapTrialManager.highestLevel = MapTrialManager.curTowerLevel end end SwitchPanel.OpenPanel(UIName.MainPanel) end -- 刷新红点 if CarbonManager.difficulty == 2 then this.TrialCopyData() elseif CarbonManager.difficulty == 1 then CheckRedPointStatus(RedPointType.NormalExplore_GetStarReward) elseif CarbonManager.difficulty == 3 then this.TrialCopyData() CheckRedPointStatus(RedPointType.HeroExplore_OpenMap) CheckRedPointStatus(RedPointType.HeroExplore_Feats) elseif CarbonManager.difficulty == CARBON_TYPE.ENDLESS then end poolManager:ClearPool() end -- 正常出图需要消除的数据 function this.ResetMapData() EndLessMapManager.srcMapId = 0 MissionManager.carBonMission = {} MapTrialManager.doneTime = 0 MapManager.isTimeOut = false this.StopWalking() end -- 换层或者换地图 function this.ChangeMapByType(nextMapId, msg) local carbonType = CarbonManager.difficulty -- 在试炼副本中的是换层操作 if carbonType == 2 then Log(Language[11239]) this.TrialChangeFloor(nextMapId, msg) elseif carbonType == 4 then Log(Language[11240]) -- 执行换图方法 this.ChangeMap(nextMapId) end end -- 试炼副本的换层操作 function this.TrialChangeFloor(nextMapId, msg) -- 设置不可点击 ctrlView.SetCtrlState(true) this.ClearBag() this.StopWalking() NetManager.MapInfoRequest(nextMapId,FormationTypeDef.FORMATION_DREAMLAND, function () local triggerCallBack triggerCallBack = function (panelType, panel) if panelType == UIName.SwitchPanel then this.Dispose() Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) end end Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- 试炼副本的完成时间 if msg.useTime then Log(Language[11241] .. msg.useTime) MapTrialManager.doneTime = msg.useTime end SwitchPanel.OpenPanel(UIName.MapPanel) MapTrialManager.isChangeLevel = false if not MapTrialManager.IsFinalLevel() then MapTrialManager.curTowerLevel = MapTrialManager.curTowerLevel + 1 end --设置 进入下一层后领取全部奖励 MissionManager.GetAllRewardTrigger() LogGreen(MapTrialManager.selectHeroDid) end) end -- 换图操作 function this.ChangeMap(nextMapId) this.ClearBag() this.StopWalking() Log(" nextMapId ====== " .. nextMapId) local index = CarbonManager.difficulty == CARBON_TYPE.ENDLESS and 401 or FormationManager.curFormationIndex NetManager.MapInfoRequest(nextMapId, index, function () local triggerCallBack triggerCallBack = function (panelType, panel) if panelType == UIName.SwitchPanel then this.Dispose() Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack) end end Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack) -- 如果是无尽副本,则需要消耗行动力 if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then -- 更新行动力 Log(Language[11242]) endLessMapView.OnRoleTransport(function () end) end SwitchPanel.OpenPanel(UIName.MapPanel) --设置 进入下一层后领取全部奖励 MissionManager.GetAllRewardTrigger() end) end -- ================================================================= -- 清除道具 function this.ClearBag() BagManager.mapShotTimeItemData = {} EquipManager.mapShotTimeItemData = {} HeroManager.mapShotTimeItemData = {} end --出图数据刷新 function this.TrialCopyData() local isPass = CarbonManager.IsMapPlayed(MapManager.curMapId) if(isPass==true) then for k, v in ConfigPairs(DifficultyData) do if(v.Id==MapManager.curMapId and v.Type==3) then if(CarbonManager.difficultyMask[v.MapId]~=-1) then if(v.DifficultType> CarbonManager.difficultyMask[v.MapId]) then CarbonManager.difficultyMask[v.MapId]=v.DifficultType end else CarbonManager.difficultyMask[v.MapId]=v.DifficultType end end end end if(CarbonManager.difficulty==2) then MapTrialManager.isCanReset=1 end end -- 角色死亡, 血量重置 function this.OnMapDeadOut(startTime, lastPos) if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then this.OnEndLessDead(lastPos) else this.OnDeadCount(startTime, lastPos) end end -- 无尽副本的死亡表现 function this.OnEndLessDead(lastPos) -- 进入死亡状态 EndLessMapManager.EndLessRoleDead = true -- 清空血条值 playerView.InitRoleHp(false) MapManager.deadTime = 0 -- 清空相应的队伍英雄血量 EndLessMapManager.DeleteMapTeam() -- 设置角色位置 playerView.SetRolePos(lastPos) -- 隐藏战斗特效 playerView.SetBattleState(false) -- 如果正在触发事件则停止 ctrlView.OnRoleDead() ctrlView.SetCtrlState(false) -- 无尽副本中死亡扣行动力 if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then endLessMapView.OnRoleDead() end end -- 死亡倒计时的表现 function this.OnDeadCount(startTime, lastPos) ctrlView.SetCtrlState(true) -- 死亡次前端无奈的加一次 MapManager.deadCount = MapManager.deadCount + 1 -- 清空血条值 playerView.InitRoleHp(false) playerView.SetBattleState(false) -- 设置角色位置 playerView.SetRolePos(lastPos) -- 如果正在触发事件则停止 ctrlView.OnRoleDead() -- 角色死亡不出图, 立马设置遮罩,让你瞎几把点 -- this.deadRoot:SetActive(true) UIManager.OpenPanel(UIName.BattleFailPopup,nil,false,nil,12) ctrlView.SetCtrlState(false) -- 无尽副本中死亡扣行动力 if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then endLessMapView.OnRoleDead() end end -- 清空寻路 function this.StopWalking() ctrlView.OnRoleDead() -- 换层时路径不一定完了,不弹完会卡死 end function this.CallListPop() ctrlView.CallListPop() end function this.Dispose() if not ctrlView.Ctrl then return end ctrlView.Dispose() playerView.Dispose() pointHandleView.Dispose() end return MapPanel