local UIMiniMapMain = UIViewClass() local UIMiniMapPointItem = require("View/MiniMap/UIMiniMapPointItem") local MAP_PATH = ConstAssetPathConfig.MAP_PATH local Ceil = math.ceil local Abs = math.abs local UPDATE_FRAME = 5 --每隔几帧刷新 local RANGE_COMBINE = 5 --几米范围内为一个点 local RANGE = RANGE_COMBINE * RANGE_COMBINE local RANGE_NUM = 10 --几个单位为一个点 local table_remove = table.remove local pairs = pairs local FP = FP local FP_V2_IsDistanceSqrGreater = FP.V2.IsDistanceSqrGreater local tonumberV2 = FP.tonumberV2 local string_format = string.format local UIUtils = UIUtils local EventID = EventID local Const_UI_Lua = Const_UI_Lua local BattleDataGetter = BattleDataGetter --玩家显示类型 local BlueType = CTL.MiniMap.MiniMapPointType.BlueNormal local RedType = CTL.MiniMap.MiniMapPointType.RedNormal local GreenType = CTL.MiniMap.MiniMapPointType.GreenNormal --战斗地图UI尺寸 local BattleSizeX = 390 local BattleSizeY = 390 local MapPointPath = ConstAssetPathConfig.MapPointPath local MapPointEffectPath = ConstAssetPathConfig.MapPointEffectPath local MapPointLabelPath = ConstAssetPathConfig.ITEM_PATH local MapPointTimerPath = ConstAssetPathConfig.MapPointTimerPath function UIMiniMapMain:OnCreated() self.mapPointDict = {} self.entityIdDict = {} self.selfMapPoint = UIMiniMapPointItem:new(0, self.img_SelfPoint) self.TownSizeX, self.TownSizeY = self.mask_Town.rectTransform:GetSizeDelta() self.cacheCountDir = {} self.LevelMapPointDic = {} --小地图元素内的地图点 self.LevelItemPointDic = {} --关卡元素的地图点 --叛军突袭的图标列表 self.rebelStrikePointList = {} -- 国战晚间Boss图标列表 self.countryNightBossPointList = {} end function UIMiniMapMain:OnOpened() self.updateInterval = 1 --刷新频率 self.hasInit = false self:RegistSystemEvent(EventID.UI_ShowMiniMap, self.ShowMiniMap) self:RegistSystemEvent(EventID.UI_HideMiniMap, self.HideMiniMap) self:RegistSystemEvent(EventID.UI_ChangeLineDone, self.UpdateLineShow) self:RegistSystemEvent(EventID.UI_MiniMap_AddMapPoint, self.OnAddMapPoint) self:RegistSystemEvent(EventID.UI_MiniMap_DeleteMapPoint, self.OnDeleteMapPoint) self:RegistSystemEvent(EventID.UI_MiniMap_MapItemAction, self.OnMapPointAction) self:RegistSystemEvent(EventID.UI_UpdateRebelStrike_MapInfo, self.UpdateRebelStrikeInfo) self:RegistSystemEvent(EventID.Update_CountryNightBoss_SceneInfo, self.UpdateCountryNightBossInfo) self:RegistSystemEvent(EventID.UI_MiniMap_HideSelf, self.HideSelf) --Item MiniMap self:RegistSystemEvent(EventID.UI_MiniMap_AddItem, self.AddItemOnMap) self:RegistSystemEvent(EventID.UI_MiniMap_DeleteItem, self.DeleteItemOnMap) self:RegistSystemEvent(EventID.UI_MiniMap_CountDownItem, self.CountItemOnMap) self:RegistSystemEvent(EventID.UI_OnTownHomeView_Open, self.SetPcScale) if BattleDataGetter.GetLevelInfoData() ~= nil and BattleDataGetter.GetCurEntity() ~= nil then self:ShowMiniMap() local itemInfoList = MDL.MiniMap.GetLevelItemList() for i,v in ipairs(itemInfoList) do self:OnAddMapPoint(v) end self:InitItemOnMap() end -- 一些场景中不需要按钮反馈 if BattleDataGetter.IsTownLevel() or BattleDataGetter.IsGuildWarWaitingArea() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) or BattleDataGetter.IsCityWarFirstStage() then self.panel_Main.enabled = true else self.panel_Main.enabled = false end self:RefreshQuitButton() if GameAppInfo.IsPCOrMacPackage() and UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UITownHome) then self:SetPcScale() end end function UIMiniMapMain:SetPcScale() CTL.Setting.SetPCViewScale(self.gameObject.transform) end function UIMiniMapMain:HideSelf(isShow) UIUtils.SetActive(self.gameObject, isShow) end function UIMiniMapMain:OnClosed() if self.miniMapPath and self.miniMapTex then TK2API.ReturnAsset(self.miniMapPath, self.miniMapTex); end if self.ConveyItemList then for _,v in ipairs(self.ConveyItemList) do TK2API.ReturnInstance(MapPointLabelPath, v.gameObject) end end for k,v in pairs(self.mapPointDict) do v:Clear() end self.mapPointDict = nil if self.selfMapPoint then self.selfMapPoint:Clear() end self.selfMapPoint = nil self:ClearCacheDir() self.cacheCountDir = nil self:ClearLevel() for i, v in ipairs(self.rebelStrikePointList) do v:Clear() self.rebelStrikePointList[i] = nil end self.rebelStrikePointList = nil for i, v in ipairs(self.countryNightBossPointList) do v:Clear() self.countryNightBossPointList[i] = nil end self.countryNightBossPointList = nil end --叛军突袭显示 function UIMiniMapMain:UpdateRebelStrikeInfo() if BattleDataGetter.IsTownLevel() == false then return end for i, v in ipairs(self.rebelStrikePointList) do v:Clear() self.rebelStrikePointList[i] = nil end local lastParentX, lastParentY = self.texture_MiniMap.rectTransform:GetLocalPosition() for _, v in LevelItemManager.GetItemIterByType(LuaConst.LevelItemType.SpawnNpcPoint) do local entity, type = v:GetMapPointInfo() if entity then local pointType = CTL.MiniMap.GetRebelStrikeType(type) local mapPointItem = UIMiniMapPointItem:new(pointType, MapPointPath, self.texture_MiniMap.transform) local posX, posY = tonumberV2(entity:GetLogicPos()) posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX - lastParentX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY - lastParentY mapPointItem:SetPointPos(posX, posY, nil) table.insert(self.rebelStrikePointList,mapPointItem) end end end -- 国战晚间Boss显示 function UIMiniMapMain:UpdateCountryNightBossInfo() if CTL.CountryNightBoss.IsChangAnLevel() then for i, v in ipairs(self.countryNightBossPointList) do v:Clear() self.countryNightBossPointList[i] = nil end local bossInfoDic = MDL.CountryNightBoss.GetBossInfoDic() local lastParentX, lastParentY = self.texture_MiniMap.rectTransform:GetLocalPosition() for bossId, bossInfo in pairs(bossInfoDic) do if not MDL.CountryNightBoss.IsBossOver(bossId) then local levelItem = BattleDataGetter.GetLevelItemByID(bossInfo.levelItemID) local pointType = CTL.MiniMap.MiniMapPointType.CountryNightBoss local mapPointItem = UIMiniMapPointItem:new(pointType, MapPointPath, self.texture_MiniMap.transform) local posX, posY = tonumberV2(levelItem.ItemData.ItemPos) posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX - lastParentX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY - lastParentY mapPointItem:SetPointPos(posX, posY, nil) table.insert(self.countryNightBossPointList, mapPointItem) end end end end --分线显示 function UIMiniMapMain:UpdateLineShow() if BattleDataGetter.IsOnlineTownLevel() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncDigTeamPVE)then UIUtils.SetActive(self.img_BgTown, true) UIUtils.SetActive(self.Img_Bg, true) if not CTL.MiniMap.IsShowChangeLine() then UIUtils.SetActive(self.lab_Branch, false) else UIUtils.SetActive(self.lab_Branch, true) self.lab_Branch.text = string_format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_MapLine), BattleDataGetter.GetCurLine()) end else UIUtils.SetActive(self.img_BgTown, false) UIUtils.SetActive(self.Img_Bg, false) end end --坐标显示 function UIMiniMapMain:UpdatePosShow() local myPos = BattleDataGetter.GetMainPlayerLastLogicPos() if (BattleDataGetter.IsTownLevel() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea)) and myPos ~= nil then self.hasSetPosEmpty = false self:SetMapPosition(myPos, self.lab_Pos) else if self.hasSetPosEmpty then return end self.lab_Pos.text = nil self.hasSetPosEmpty = true end end --设置当前坐标 function UIMiniMapMain:SetMapPosition(myPos, comp) if self.playerPosX == nil then self.playerPosX = 0 end if self.playerPosY == nil then self.playerPosY = 0 end local posX, posY = tonumberV2(myPos) posX = Ceil(posX) posY = Ceil(posY) if (self.playerPosX and self.playerPosX ~= posX) or (self.playerPosY and self.playerPosY ~= posY) then UIUtils.SetLabel(comp, string_format("(%s,%s)", posX, posY)) self.playerPosX = posX self.playerPosY = posY end end function UIMiniMapMain:RefreshQuitButton() if LevelManager.IsGuildPartyLevel() then UIUtils.SetActive(self.event_Quit, true); else UIUtils.SetActive(self.event_Quit, false); end end function UIMiniMapMain:OnButtonClicked(comp) if comp == self.panel_Main then if BattleDataGetter.IsTownLevel() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIMiniMapWorld) elseif BattleDataGetter.IsGuildWarWaitingArea() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarMapInfo) end elseif comp == self.event_Quit then if LevelManager.IsGuildPartyLevel() then MDL.GuildParty.ReqExitGuildPartyMap(); elseif BattleDataGetter.IsSatelliteTown() then MDL.Level.ReqExitSatelliteTown() end end end --特殊需求,需要隐藏该界面 function UIMiniMapMain:HideMiniMap() self:StopRepeatFunc(self.OnUpdateFun) UIUtils.SetActive(self.panel_MiniMap, false) UIUtils.SetActive(self.bg_MiniMap, false) self.hasInit = false end function UIMiniMapMain:ShowMiniMap() if self.hasInit then return end self.hasInit = true self.MapPosX = 0 self.MapPosY = 0 local levelInfoData = BattleDataGetter.GetLevelInfoData() self.miniMapData = DataSheetManager.MiniMapData:GetDataByID(levelInfoData.SceneMapID) self.miniMapPath = string_format(MAP_PATH, self.miniMapData.SceneMap) self.miniMapTex = TK2API.GetTextureAsset(self.miniMapPath) self.texture_MiniMap.texture = self.miniMapTex --配置的缩放倍数*1000 self.TownMapScaleRate = self.miniMapData.MapZoomRate / 1000 if self.TownMapScaleRate > 0 then UIUtils.SetActive(self.bg_MiniMap, false) UIUtils.SetActive(self.bg_Town, true) self.MapSizeX = self.TownSizeX self.MapSizeY = self.TownSizeY UIUtils.SetGraphicSize(self.texture_MiniMap, self.MapSizeX * self.TownMapScaleRate, self.MapSizeY * self.TownMapScaleRate) UIUtils.SetActive(self.img_MapFrame, false) UIUtils.SetActive(self.mask_Town, true) UIUtils.SetParent(self.texture_MiniMap,self.mask_Town) UIUtils.SetParent(self.group_MapItem,self.mask_Town) self.group_MapItem:SetLocalPosition(0, 0, 0) self.texture_MiniMap.transform:SetLocalScale(1, 1, 1) self.group_MapItem.transform:SetLocalScale(1, 1, 1) else self.MapSizeX = BattleSizeX self.MapSizeY = BattleSizeY UIUtils.SetActive(self.bg_MiniMap, true) UIUtils.SetActive(self.bg_Town, false) UIUtils.SetGraphicSize(self.texture_MiniMap, self.MapSizeX, self.MapSizeY) UIUtils.SetActive(self.mask_Town, false) UIUtils.SetActive(self.img_MapFrame, true) UIUtils.SetParent(self.texture_MiniMap, self.img_MapMask) UIUtils.SetLocalPosition(self.texture_MiniMap,0, 0, 0) UIUtils.SetAsFirstSibling(self.texture_MiniMap) --保证地图的元素点要跟texture_MiniMap在同个坐标系下 UIUtils.SetParent(self.group_MapItem,self.texture_MiniMap) self.group_MapItem:SetLocalPosition(0, 0, 0) UIUtils.SetParent(self.group_MapItem,self.img_ItemMask) self.texture_MiniMap.transform:SetLocalScale(0.87, 0.87, 1) self.group_MapItem.transform:SetLocalScale(0.87, 0.87, 1) UIUtils.SetRectTransformSize(self.panel_MiniMap, self.MapSizeX, self.MapSizeY) end if self.TownMapScaleRate > 0 or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncDigTeamPVE) then UIUtils.SetLabelText(self.lab_TownName, Const_IDS[levelInfoData.LevelNameIDS]) end UIUtils.SetActive(self.panel_MiniMap, true) self:CalMiniMapParam(self.miniMapTex.width) --传送门 self:LoadLevelConveyItem() self:UpdateMapPoint() --坐标显示 self:UpdatePosShow() --分线 self:UpdateLineShow() --叛军突袭 self:UpdateRebelStrikeInfo() -- 国战晚间boss self:UpdateCountryNightBossInfo() --注册Update self:StartRepeatFunc(self.OnUpdateFun, self.updateInterval) end function UIMiniMapMain:LoadLevelConveyItem() if BattleDataGetter.IsOnlineTownLevel() and self.ConveyItemList then return end local conveyItemList = LevelItemManager.GetItemListByType(LuaConst.LevelItemType.Convey) if conveyItemList then self.ConveyItemList = {} for _,v in ipairs(conveyItemList) do local item = TK2API.GetInstance(MapPointLabelPath,self.texture_MiniMap.transform) local label = UIUtils.GetLocalizationTextFromChild(item,0) local itemData = v.ItemData if itemData then UIUtils.SetLabelText(label,Const_IDS[itemData.Name]) local posX, posY = tonumberV2(itemData.ItemPos) local fixPosX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX local fixPosY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY UIUtils.SetLocalPosition(item,fixPosX, fixPosY, 0) table.insert(self.ConveyItemList,item) end end end end function UIMiniMapMain:CalMiniMapParam(texSize) local miniMapData = self.miniMapData local mapSize = miniMapData.UIMapSize > 0 and miniMapData.UIMapSize or texSize --缩放比例 self.SizeRateX = self.MapSizeX / texSize self.SizeRateY = self.MapSizeY / texSize local uiMapRate = (miniMapData.OriMapSize > 0 and miniMapData.UIMapSize > 0) and (miniMapData.UIMapSize / miniMapData.OriMapSize) or 1 if miniMapData.IsCombine == 1 then self.OffsetX = (mapSize / uiMapRate) / 2 + miniMapData.MapOffsetX self.OffsetY = (mapSize / uiMapRate) / 2 + miniMapData.MapOffsetY else local xMax, zMax, offsetX, offsetZ = BattleExt.GetCurMapInfo() self.OffsetX = xMax / 2 + offsetX self.OffsetY = zMax / 2 + offsetZ end if self.TownMapScaleRate > 0 then self.SizeRateX = self.SizeRateX * self.TownMapScaleRate self.SizeRateY = self.SizeRateY * self.TownMapScaleRate end self.SizeRateX = self.SizeRateX * uiMapRate self.SizeRateY = self.SizeRateY * uiMapRate end function UIMiniMapMain:OnUpdateFun(deltaTime, timeSinceUpdate) if LevelItemManager.IsShowingMovie() then return end self:UpdatePosShow() self:UpdateMapPoint() --关卡控制元素移动 if self.MovingMapPointList then for i = #self.MovingMapPointList, 1, -1 do if self.MovingMapPointList[i]:MoveToTarget() then table_remove(self.MovingMapPointList, i) end end end end function UIMiniMapMain:UpdateMapPoint() --更新主角 local myEntity = BattleDataGetter.GetCurEntity() if self.TownMapScaleRate > 0 then local angle = self:GetRotateAngle(myEntity) self.selfMapPoint:SetPointPos(0, 0, angle) --主角不动,地图动 local posX, posY = self:GetMapMovePos() if self.MapPosX ~= posX or self.MapPosY ~= posY then UIUtils.SetLocalPosition(self.texture_MiniMap,posX, posY, 0) self.MapPosX = posX self.MapPosY = posY end else self:UpdatePointPos(myEntity, self.selfMapPoint, true) end --更新其他元素 self:ClearCacheDir() local index = 0 local entityDic = BattleDataGetter.GetEntityDic() local myCountryId = BattleDataGetter.GetEntityCountryInfo(myEntity) table.clear(self.entityIdDict) for _, entity in pairs(entityDic) do if entity ~= myEntity and entity.components.base.IsActive == true then local type, effect = self:GetMapShowType(entity, myCountryId) if type then index = index + 1 --多传一个entity参数,给继承的小地图用 local mapPointItem = self:GetMapPoint(index, type, effect, entity) self:UpdatePointPos(entity, mapPointItem, false) self.entityIdDict[entity:GetEntityID()] = true end end end for k,v in pairs(self.mapPointDict) do if not self.entityIdDict[k] then v:SetActive(false) end end end --获取entity在小地图上的类型,返回nil不显示 function UIMiniMapMain:GetMapShowType(entity) local showRedPointType = entity.ExpEntity.ShowRedPointType if showRedPointType and showRedPointType > 0 then if self:IsAddMapPoint(entity, showRedPointType) then local itemData = BattleDataGetter.GetBornItemData(entity) --地图上显示的特效以中心实体的特效配置为准,已经和策划对过了 return showRedPointType, itemData.RedPointEffect end end if entity:IsHero() and entity:IsAlive() then -- 押镖场景需要特殊处理 if LevelManager.GetCurLevelType() == LuaConst.LevelType.CrossEscortTown or LevelManager.GetCurLevelType() == LuaConst.LevelType.SingleEscortTown then if CTL.Team.IsMemberInTeam(entity._logicInitData.Acid) then -- 如果是队友显示绿色 return GreenType else local countryId = BattleDataGetter.GetEntityCountryInfo(entity) if MDL.Country.IsSameCountry(countryId) then -- 如果是同国家 return BlueType else -- 不是同国家全是敌人 return RedType end end else if CampManager.IsEnemyCamp(entity:GetCampID(), LevelPlayerManager.MainEntityCampID) then return RedType else return BlueType end end end return nil end function UIMiniMapMain:GetMapMovePos() local myPos = BattleDataGetter.GetMainPlayerLastLogicPos() if myPos ~= nil then local posX, posY = tonumberV2(myPos) posX = -(posX - self.OffsetX) * self.SizeRateX posY = -(posY - self.OffsetY) * self.SizeRateY return posX, posY end return 0, 0 end function UIMiniMapMain:UpdatePointPos(entity, mapPointItem, needRot) if entity and mapPointItem then local posX, posY = tonumberV2(entity:GetLogicPos()) posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY if needRot then local angle = self:GetRotateAngle(entity) mapPointItem:SetPointPos(posX, posY, angle) else mapPointItem:SetPointPos(posX, posY, nil) end end end function UIMiniMapMain:GetRotateAngle(entity) if entity == nil then return 0 end local rotY = entity.ExpEntity:GetEulerAngleY() return rotY * (-1) end function UIMiniMapMain:IsAddMapPoint(entity, showRedPointType) --放大显示,不在视野范围内不显示 if self.TownMapScaleRate > 0 then local posX, posY = tonumberV2(entity:GetLogicPos()) posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY if Abs(posX) >= self.MapSizeX / 2 or Abs(posY) >= self.MapSizeY / 2 then return false end end local logicPos = entity.components.move.LogicPos for cacheEntity, num in pairs(self.cacheCountDir) do local pos = cacheEntity.components.move.LogicPos local redPointType = cacheEntity.ExpEntity.ShowRedPointType if redPointType == showRedPointType and not FP_V2_IsDistanceSqrGreater(pos, logicPos, RANGE) then num = num + 1 if num >= RANGE_NUM then self.cacheCountDir[cacheEntity] = nil else self.cacheCountDir[cacheEntity] = num end return false end end self.cacheCountDir[entity] = 1 return true end function UIMiniMapMain:GetMapPoint(index, type, effect, entity, mapPointPath) local entityId = entity:GetEntityID() local mapPointItem = self.mapPointDict[entityId] if not mapPointItem then mapPointPath = mapPointPath or MapPointEffectPath mapPointItem = UIMiniMapPointItem:new(type, mapPointPath, self.group_MapItem) mapPointItem:PlayPointEffect(effect) self.mapPointDict[entityId] = mapPointItem else mapPointItem:SetActive(true) local lastType = mapPointItem.PointType mapPointItem:SetPointImage(type) if lastType ~= type then if string.isNilOrEmpty(effect) then mapPointItem:StopAllEffect() else mapPointItem:PlayPointEffect(effect) end end end return mapPointItem end function UIMiniMapMain:ClearCacheDir() for k, v in pairs(self.cacheCountDir) do self.cacheCountDir[k] = nil end end function UIMiniMapMain:InitItemOnMap() for i, itemID in BattleDataGetter.GetMapItemIDIter() do local item = BattleDataGetter.GetItemByID(itemID) self:AddItemOnMap(itemID, item.ItemData) if item.GetMinimapTimer then local timer = item:GetMinimapTimer() if timer then self:CountItemOnMap(itemID, timer) end end end end function UIMiniMapMain:AddItemOnMap(itemID, itemData) if not self.LevelItemPointDic[itemID] then local type = itemData.UnbornRedPointType or itemData.ShowRedPointType local point = UIMiniMapPointItem:new(type, MapPointTimerPath, self.group_MapItem) local posX, posY = tonumberV2(itemData.ItemPos) point:InitUITimer() posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY point:SetPointPos(posX, posY) self.LevelItemPointDic[itemID] = point end end function UIMiniMapMain:DeleteItemOnMap(itemID) if self.LevelItemPointDic[itemID] then self.LevelItemPointDic[itemID]:Clear() self.LevelItemPointDic[itemID] = nil end end function UIMiniMapMain:CountItemOnMap(itemID, time) if self.LevelItemPointDic[itemID] then self.LevelItemPointDic[itemID]:StartCountDown(time) end end --显示地图元素 function UIMiniMapMain:OnAddMapPoint(item) local itemData = item.ItemData local point = self.LevelMapPointDic[itemData.LevelItemID] if not point then local parent = self.group_MapItem local type = itemData.redPointType if itemData.OperType == LuaConst.MiniMapOperType.MiniMapArea then parent = self.panel_HoldArea type = 0 end point = UIMiniMapPointItem:new(type, MapPointEffectPath ,parent) self.LevelMapPointDic[itemData.LevelItemID] = point end point:InitLevelPara(self, itemData) if item.StressEffect then point:PlayStressEffect(item.StressEffect) end end --删除地图元素 function UIMiniMapMain:OnDeleteMapPoint(item) local itemData = item.ItemData local point = self.LevelMapPointDic[itemData.LevelItemID] if point then point:Clear() self.LevelMapPointDic[itemData.LevelItemID] = nil end end --处理地图元素事件 function UIMiniMapMain:OnMapPointAction(actionType, itemData, param1, param2) if itemData == nil then return end local mapItem = self.LevelMapPointDic[itemData.LevelItemID] if mapItem == nil then logging.error(LTAG.ERROR, "LevelItem not inits or not exits,LevelItemID is ", itemData.LevelItemID) return end if actionType == LuaConst.LevelActionType.MiniMap_Deactive then mapItem:SetActive(false) elseif actionType == LuaConst.LevelActionType.MiniMap_MoveTarget then local targetItem = self.LevelMapPointDic[param1] if targetItem == nil then logging.error(LTAG.ERROR, "Target LevelItem not inits or not exits,LevelItemID is ", itemData.LevelItemID) return end if self.MovingMapPointList == nil then self.MovingMapPointList = {} end mapItem:SetTargetInfo(targetItem, param2) table.insert(self.MovingMapPointList, mapItem) elseif actionType == LuaConst.LevelActionType.MiniMap_HighLight_Active then mapItem:HighLightState(true) elseif actionType == LuaConst.LevelActionType.MiniMap_HighLight_Deactive then mapItem:HighLightState(false) elseif actionType == LuaConst.LevelActionType.MiniMap_ShowStressEffect then mapItem:StopAllEffect() if param1 then mapItem:PlayStressEffect(param1) end end end --清理关卡地图元素 function UIMiniMapMain:ClearLevel() if self.LevelMapPointDic then for k, item in pairs(self.LevelMapPointDic) do item:Clear() self.LevelMapPointDic[k] = nil end end self.LevelMapPointDic = nil if self.MovingMapPointList then for k, item in pairs(self.MovingMapPointList) do item:Clear() self.MovingMapPointList[k] = nil end end self.MovingMapPointList = nil if self.LevelItemPointDic then for k, item in pairs(self.LevelItemPointDic) do item:Clear() self.LevelItemPointDic[k] = nil end end self.LevelItemPointDic = nil end return UIMiniMapMain