---@class KLBigMapPanel:UIKmlLuaPanelBase ---@field view KLBigMapPanelView local KLBigMapPanel = class(UIKmlLuaPanelBase) local this = KLBigMapPanel ---@class MapMoveListItemData ---@field isGroup boolean ---@field isRoot boolean ---@field groupExpand boolean ---@field children cfg_mapMove_column[] ---@field data cfg_mapMove_column ---创建时调用一次 function this:Init() --self.controlMap = {} --self.mapMoveTabList = {} self.mapMoveGroup = {} ---@type MapMoveListItemData[] self.mapMoveListData = {} ---随机传送道具相关初始化 self:InitDeliveryItemData() ---定点传送道具相关初始化 self:InitFixedPointItemData() self.MonsterPointPool = TablePool()---大地图 self.monsterPointTempList = {}---temp列表保存 --[[ self.specialMonsterPointPool = TablePool()---大地图 self.specialMonsterPointTempList = {}---temp列表保存]] ---@type cfg_mapMove_column[] local mapMoveTabList = SL:GetConfigTable("cfg_mapMove") for _, v in pairs(mapMoveTabList) do if SL:CheckCalculateConditionGroup(v.mapUIShow) then if v.group and v.group ~= 0 then --如果有分组 if not self.mapMoveGroup[v.group] then self.mapMoveGroup[v.group] = {} ---@type MapMoveListItemData local item = {} item.isGroup = true item.data = v item.isRoot = true table.insert(self.mapMoveListData, item) end ---@type MapMoveListItemData local item = {} item.isGroup = false item.data = v item.isRoot = false table.insert(self.mapMoveGroup[v.group], item) else ---@type MapMoveListItemData local item = {} item.isGroup = false item.data = v item.isRoot = true table.insert(self.mapMoveListData, item) end end end --填充children for _, v in pairs(self.mapMoveListData) do if v.isGroup then v.children = self.mapMoveGroup[v.data.group] end end --[[ GUI:DataListInitData(self.view.TransferList, function() return self:TransferListCountGetFun() end, function(realIndex) return self:TransferListGetFun(realIndex) end, nil, function(realIndex,item) self:TransferListUpdateFun(realIndex,item) end, nil)]] GUI:OSAScrollView_Initialized(self.view.TransferScrollView, self.TransferItemGetFun, self.TransferItemUpdateFun, self) GUI:OSAScrollView_SetItemSizeGetFun(self.view.TransferScrollView, self.TransferItemSizeGetFun, self) ---@type table self.iconMap = {} self.sceneImgWidth, self.sceneImgHeight = GUI:getSizeDelta(self.view.img_scene) self.showedRoadPoints = {} self.mapIconVisibleInfo = {} ---@type KLMiniMapPanel local minimapPanel = GUI:GetUI("dev/ui/Map/Panel/KLMiniMap/KLMiniMapPanel") if minimapPanel then for k, v in pairs(minimapPanel.mapIconVisibleInfo) do self.mapIconVisibleInfo[k] = v end end end function this:TransferItemSizeGetFun(index) local data = self.mapMoveListData[index + 1] if data.isRoot then return 46 end return 34 end function this:TransferItemGetFun() ---@type KLBigMapTransferItemItem local itemPanel = GUI:UIPanel_Open("dev/ui/Map/Item/KLBigMapTransferItem/KLBigMapTransferItemItem", self.view.TransferList, self, nil, true) return itemPanel end ---@param item KLBigMapTransferItemItem ---@param index number function this:TransferItemUpdateFun(item, index) item:RefreshUI(self.mapMoveListData[index + 1], function() self:RefreshListData() --GUI:DataListUpdateData(self.view.TransferList) self:RefreshTransferList() end) end --[[function this:TransferListCountGetFun() return #self.mapMoveListData end]] --[[function this:TransferListGetFun() local itemPanel = GUI:UIPanel_Open("dev/ui/Map/Item/KLBigMapTransferItem/KLBigMapTransferItemItem",self.view.TransferList,self,nil,true) self.controlMap[itemPanel.view.root.kmlControl] = itemPanel return itemPanel.view.root.kmlControl end]] --[[ function this:TransferListUpdateFun(realIndex,item) ---@type KLBigMapTransferItemItem local itemPanel = self.controlMap[item] itemPanel:RefreshUI(self.mapMoveListData[realIndex + 1], function() self:RefreshListData() --GUI:DataListUpdateData(self.view.TransferList) self:RefreshTransferList() end) end ]] function this:RefreshListDataWithJumpIndex(jumpIndex) ---@type cfg_mapMove_column local jumpTbl = SL:GetConfig("cfg_mapMove", jumpIndex) if jumpTbl.group ~= 0 then --展开分组 for _, v in pairs(self.mapMoveListData) do if v.isGroup and v.data.group == jumpTbl.group then if not v.groupExpand then v.groupExpand = true self:RefreshListData() end end end end for k, v in pairs(self.mapMoveListData) do if not v.isGroup and v.data.id == jumpTbl.id then return k end end end function this:RefreshListData() local newListData = {} for _, item in pairs(self.mapMoveListData) do if item.isRoot then table.insert(newListData, item) if item.isGroup and item.groupExpand and item.children then for _, child in pairs(item.children) do table.insert(newListData, child) end end end end self.mapMoveListData = newListData end ---创建或者刷新界面数据时调用 function this:Refresh() SL.HideMainPanel() GUI:Slider_setPercent(self.view.slider_map_size, 1.00001) self:SetDeliveryItem() self:SetFixedPointItem() GUI:AddOnClickEvent(self.view.Delivery_Item, self, function() local count = SL:GetBagItemCount(self.DeliveryItemID) if count < 1 then SL:CommonTipsMessage({ stringTblID = 494, ui = self, sureBtnText = "确定", cancelBtnText = "取消", callback = function() self:BtnCloseOnClick() shortcutOutMgr.DO(self.DeliveryItemJumpPathList) end }) return end local item_Data = SL:MeData_GetCfgBaseOnItemId(self.DeliveryItemID) if item_Data then self.isUseDelivery = true self:ClearAllRoadPoint() SL:UseItem(self.DeliveryItemID, item_Data.id, 1) end end) --GUI:DataListUpdateData(self.view.TransferList) local jumpListIndex if self.args then local jumpIndex = tonumber(self.args[1]) jumpListIndex = self:RefreshListDataWithJumpIndex(jumpIndex) end self:RefreshTransferList() if jumpListIndex then GUI:OSAScrollView_ScrollTo(self.view.TransferScrollView, jumpListIndex - 1) end local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID) ---@type cfg_map_info_column local mapInfo = SL:GetConfig("cfg_map_info", mapId) self.initMapScale = mapInfo.showSize or 1 self.initPivot = { 0.5, 0.5 } self.iconScale = 1 / self.initMapScale if mapInfo.showPosition then self.initPivot = mapInfo.showPosition GUI:SetAnchorAdvanced(self.view.panel_scene, self.initPivot[1], self.initPivot[2]) GUI:setPosition(self.view.panel_scene, 0, 0) end GUI:setScale(self.view.panel_scene, self.initMapScale) GUI:setScale(self.view.img_player_icon, self.iconScale) local mapFile = SL:GetMetaValue(EMetaVarGetKey.MINIMAP_FILE) GUI:Image_loadTexture(self.view.img_scene, string.format("Texture/%s.png", mapFile)) self:SetTransferIcon() self:SetNpcIcon() self:ZoomMap(1) self:ShowCurPath() self:ShowPlayerIcon() SL:ReqMapMonsterStatusMessage(mapId) ---设置npc传送列表 GUI:AddOnClickEvent(self.view.btn_npc_transfer1, self, self.TransferToCompoundNpc) ---地图名称 GUI:Text_setString(self.view.text_map_name, SL:GetMetaValue(EMetaVarGetKey.MAP_NAME)) if not SL:GetIsWebGL() then GUI:setAnchorPoint(self.view.btn_close,2,1) GUI:setPosition(self.view.btn_close, 4, -48) end end function this:TransferToCompoundNpc() self:BtnCloseOnClick() SL:SendTransferToNpcMessage(100404, true) --SL:ScheduleOnce(1, function() -- if not GUI:GetUI("dev/outui/UISynthesis/Panel/KLUISynthesis/KLUISynthesisPanel") then -- GUI:UIPanel_Open("dev/outui/UISynthesis/Panel/KLUISynthesis/KLUISynthesisPanel", nil, nil, {}) -- end --end) end function this:RefreshTransferList() GUI:OSAScrollView_RefreshList(self.view.TransferScrollView, #self.mapMoveListData) end ---初始化随机传送道具信息 function this:InitDeliveryItemData() ---随机传送道具id self.DeliveryItemID = 60010001 ---随机传送道具的跳转路径 self.DeliveryItemJumpPathList = { "openUIPanel", "dev/outui/ShopMain/Panel/KLShopMain/KLShopMainPanel", "1", "1" } ---@type cfg_item_column local itemCfg = SL:GetConfig("cfg_item", self.DeliveryItemID) for i, v in ipairs(itemCfg.Quickshopping) do if v[1] == "2" and v[3] == "商城" and v[4] == "openUIPanel" then self.DeliveryItemJumpPathList = {} for z, a in ipairs(v) do if z > 3 then table.insert(self.DeliveryItemJumpPathList, a) end end break end end end ---初始化定点传送道具信息 function this:InitFixedPointItemData() ---@type cfg_global_column local globalCfg = SL:GetConfig("cfg_global", 25003) local strList = string.split(globalCfg.value, '#') ---定点传送道具id self.FixedPointItemID = tonumber(strList[1]) ---定点传送道具所需数量 self.FixedPointItemNeedCount = tonumber(strList[2]) ---是否勾选了定点传送 self.isSelectFixedPoint = false ---定点传送道具的跳转路径 self.FixedPointItemJumpPathList = { "openUIPanel", "dev/outui/ShopMain/Panel/KLShopMain/KLShopMainPanel", "1", "1" } ---@type cfg_item_column local itemCfg = SL:GetConfig("cfg_item", self.FixedPointItemID) for i, v in ipairs(itemCfg.Quickshopping) do if v[1] == "2" and v[3] == "商城" and v[4] == "openUIPanel" then self.FixedPointItemJumpPathList = {} for z, a in ipairs(v) do if z > 3 then table.insert(self.FixedPointItemJumpPathList, a) end end break end end self.isSelectFixedPoint = PlayerPrefs.GetInt("SelectFixedPoint" .. SL:GetMetaValue(EMetaVarGetKey.UID)) == 1 GUI:Toggle_setIsOn(self.view.FixedPointToggle, self.isSelectFixedPoint) end ---设置随机传送道具的数量,id,数量文本颜色 function this:SetDeliveryItem() local count = SL:GetBagItemCount(self.DeliveryItemID) local colorStr = "#fbd994" if count < 1 then colorStr = "#ff2323" end GUI:Item_UpdataData(self.view.Delivery_Item, { itemid = tostring(self.DeliveryItemID), itemcustomcount = "" .. SL:GetBagItemCount(self.DeliveryItemID) .. "", }) end ---设置定点传送道具的id function this:SetFixedPointItem() local count = SL:GetBagItemCount(self.FixedPointItemID) local colorStr = "#fbd994" if count < 1 then colorStr = "#ff2323" end GUI:Text_setString(self.view.FixedPointItemCount, "" .. SL:GetSimpleNumber(SL:GetBagItemCount(self.FixedPointItemID), 1) .. "") GUI:Item_UpdataData(self.view.FixedPointItem, { itemid = tostring(self.FixedPointItemID), itemcustomcount = "", mscale = "25,25,25", }) end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnTouchEvent(self.view.img_drag, self, self.OnSceneTouch1) GUI:AddOnTouchEvent(self.view.img_scene, self, self.OnSceneTouch2) GUI:AddOnClickEvent(self.view.btn_close, self, self.BtnCloseOnClick) GUI:Slider_addOnEvent(self.view.slider_map_size, self, self.SliderMapSizeOnEvent) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_MAPPOS_CHANGE, self.OnPlayerMapPosChange, self) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_TURN_DIR, self.OnPlayerTurnDir, self) SL:RegisterLUAEvent(LUA_EVENT_BAG_CHANGE_AFTER, self.LUA_EVENT_BAG_CHANGE_AFTER, self) GUI:AddOnClickEvent(self.view.btn_map_zoom_in, self, self.BtnMapZoomInOnClick) GUI:AddOnClickEvent(self.view.btn_map_zoom_out, self, self.BtnMapZoomOutOnClick) GUI:AddOnClickEvent(self.view.FixedPointItem, self, self.BtnFixedPointItemOnClick) SL:RegisterLuaNetMsg(MessageDef.ResMapMonsterStatusMessage, self.ResMapMonsterStatusMessage, self) ---特别袖珍罐商店 GUI:AddOnClickEvent(self.view.btn_npc_shop1, self, self.TransferToShopNpc) GUI:SetToggleOnValueChange(self.view.FixedPointToggle, self, self.FixedPointToggleChange) end ---点击定点道具显示tips function this:BtnFixedPointItemOnClick() SL:OpenTips("", self.FixedPointItemID) end function this:FixedPointToggleChange(control, eventData, value) self.isSelectFixedPoint = value[1] PlayerPrefs.SetInt("SelectFixedPoint" .. SL:GetMetaValue(EMetaVarGetKey.UID), value[1] and 1 or 0) end function this:LUA_EVENT_BAG_CHANGE_AFTER(_, message) if message then self:SetDeliveryItem() self:SetFixedPointItem() end end function this:OnSceneTouch1(_, touchType) if touchType == EUIEventName.OnBeginDrag then self.beginDragPos = SL:GetMetaValue(EMetaVarGetKey.MOUSE_MOVE_POS) self.beginMapPosX, self.beginMapPosY = GUI:getPosition(self.view.panel_scene) elseif touchType == EUIEventName.OnDrag then if not self.beginDragPos then return end local pos = SL:GetMetaValue(EMetaVarGetKey.MOUSE_MOVE_POS) local delta = pos - self.beginDragPos local finalPosX = self.beginMapPosX + delta[0] local finalPosY = self.beginMapPosY + delta[1] local fac = 1 / self.iconScale * 0.5 if finalPosX < -self.sceneImgWidth * fac then finalPosX = -self.sceneImgWidth * fac elseif finalPosX > self.sceneImgWidth * fac then finalPosX = self.sceneImgWidth * fac end if finalPosY < -self.sceneImgHeight * fac then finalPosY = -self.sceneImgHeight * fac end if finalPosY > self.sceneImgHeight * fac then finalPosY = self.sceneImgHeight * fac end GUI:setPosition(self.view.panel_scene, finalPosX, finalPosY) elseif touchType == EUIEventName.OnEndDrag then self.beginDragPos = nil end end function this:OnSceneTouch2(_, touchType) if touchType == EUIEventName.OnBeginDrag then self.beginDragPos = SL:GetMetaValue(EMetaVarGetKey.MOUSE_MOVE_POS) self.beginMapPosX, self.beginMapPosY = GUI:getPosition(self.view.panel_scene) self.oldSceneTouchType = EUIEventName.OnBeginDrag elseif touchType == EUIEventName.OnDrag then if not self.beginDragPos then return end local pos = SL:GetMetaValue(EMetaVarGetKey.MOUSE_MOVE_POS) local delta = pos - self.beginDragPos local finalPosX = self.beginMapPosX + delta[0] local finalPosY = self.beginMapPosY + delta[1] local fac = 1 / self.iconScale * 0.5 if finalPosX < -self.sceneImgWidth * fac then finalPosX = -self.sceneImgWidth * fac elseif finalPosX > self.sceneImgWidth * fac then finalPosX = self.sceneImgWidth * fac end if finalPosY < -self.sceneImgHeight * fac then finalPosY = -self.sceneImgHeight * fac end if finalPosY > self.sceneImgHeight * fac then finalPosY = self.sceneImgHeight * fac end GUI:setPosition(self.view.panel_scene, finalPosX, finalPosY) elseif touchType == EUIEventName.OnEndDrag then self.beginDragPos = nil elseif touchType == EUIEventName.OnPointerClick then --点击拖拽的时候也会调用这个事件 需要判断一下是不是拖拽 if self.oldSceneTouchType == EUIEventName.OnBeginDrag then self.oldSceneTouchType = nil return end local posX, posY = self:GetCurrentMousePosInMap() if self.isSelectFixedPoint then --选择了定点传送 if not SL:GetMetaValue(EMetaVarGetKey.MAP_IS_OBSTACLE, math.round(posX), math.round(posY)) then --不为阻挡点 local count = SL:GetBagItemCount(self.FixedPointItemID) if count < self.FixedPointItemNeedCount then SL:CommonTipsMessage({ stringTblID = 497, ui = self, sureBtnText = "确定", cancelBtnText = "取消", callback = function() self:BtnCloseOnClick() shortcutOutMgr.DO(self.FixedPointItemJumpPathList) end }) return end self:ClearAllRoadPoint() SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRANSFER_WITHIN_MAP, { math.round(posX), math.round(posY) }) else SL:TipMessage(SL:GetConfig('cfg_string', 498).text, 1, NoticeType.NoticeMid) end return end ---@type ArriveFuncData local arriveFuncData = {} arriveFuncData.IsAutoFight = true arriveFuncData.callBack = function() local isSafe = SL:GetMetaValue(EMetaVarGetKey.IN_SAFE_AREA) if not isSafe then SL:StartOnHook(true, true) end end SL:StopOnHook(true) local roadRight = SL:Me_TriggerToMove(Dot2.New(math.round(posX), math.round(posY)), nil, nil, arriveFuncData, true, nil, nil, true, true) if roadRight then self:ShowCurPath() end elseif touchType == EUIEventName.onDoublePointerClick then if SL:GetMetaValue("PLATFORM_MOBILE") and SL:GetMetaValue("IS_SDK_LOGIN") then return end self:ClearAllRoadPoint() local posX, posY = self:GetCurrentMousePosInMap() SL:MapTransferXY(0, math.round(posX), math.round(posY)) end end function this:BtnCloseOnClick() GUI:UIPanel_Close("dev/ui/Map/Panel/KLBigMap/KLBigMapPanel") end function this:Close() if self.iconMap then for k, v in pairs(self.iconMap) do GUI:UIPanel_Close(_, v) end table.clear(self.iconMap) end --[[for _, point in pairs(self.showedRoadPoints) do point.kmlControl:Hide() end table.clear(self.showedRoadPoints) if self.roadPointStack then while not self.roadPointStack:IsEmpty() do local point = self.roadPointStack:Pop() point.kmlControl:Hide() end end]] self.MonsterPointPool:Clear() self.monsterPointTempList = {}---temp列表保存 --[[ self.specialMonsterPointPool:Clear() self.specialMonsterPointTempList = {}---temp列表保存]] if self.DeliveryTimer then SL:UnSchedule(self.DeliveryTimer) end SL.ShowMainPanel() end function this:GetCurrentMousePosInMap() local pos = SL:GetMetaValue(EMetaVarGetKey.MOUSE_MOVE_POS) local _, relativePos = SL:ScreenPointToLocalPointInRectangle(self.view.panel_scene, pos[0], pos[1]) local clickPosX = relativePos[0] + self.sceneImgWidth * self.initPivot[1] local clickPosY = relativePos[1] + self.sceneImgHeight * self.initPivot[2] clickPosX = clickPosX / self.sceneImgWidth * 256 clickPosY = clickPosY / self.sceneImgHeight * 256 return clickPosX, clickPosY end ---@设置传送点图标 function this:SetTransferIcon() local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID) ---@type cfg_transfer_point_column[] local transferPoint = SL:FindConfigs('cfg_transfer_point', 'mapId', mapId) if transferPoint then for _, v in pairs(transferPoint) do local transferIcon = GUI:UIPanel_Open("dev/ui/Map/Item/KLMapTransferIcon/KLMapTransferIconItem", self.view.icon_parent, self, v, true) self:SetMapIcon("MapTransferIcon" .. v.id, transferIcon, v.position[1], v.position[2]) end end end function this:SetNpcIcon() local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID) ---@type cfg_npclist_column[] local npcList = SL:FindConfigs('cfg_npclist', 'mapId', mapId) if npcList then for _, npcTbl in pairs(npcList) do local npcIcon = GUI:UIPanel_Open("dev/ui/Map/Item/KLMapNpcIcon/KLMapNpcIconItem", self.view.icon_parent, self, { npcTbl, true }, true) self:SetMapIcon("MapNpcIcon" .. npcTbl.id, npcIcon, npcTbl.x, npcTbl.y) end end end ---@param id string ---@param item UIKmlLuaPanelBase function this:SetMapIcon(id, item, x, y) if self.iconMap[id] then GUI:UIPanel_Close(_, self.iconMap[id]) self.iconMap[id] = nil end --GUI:SetParent(icon,self.view.scene_group) --item.kmlControl:SetParent(self.view.icon_parent.kmlControl) local miniMapX = x / 256 * self.sceneImgWidth - self.sceneImgWidth / 2 local miniMapY = y / 256 * self.sceneImgHeight - self.sceneImgHeight / 2 GUI:setPosition(item.view.root, miniMapX, miniMapY) self.iconMap[id] = item if self.mapIconVisibleInfo[id] then GUI:setVisible(item.view.root, self.mapIconVisibleInfo[id] == "1") end end ---@return UIKmlLuaControl function this:PopRoadPoint() if not self.roadPointStack then self.roadPointStack = Stack:New() end local point if self.roadPointStack:Count() > 0 then point = self.roadPointStack:Pop() else point = GUI:Image_Create(self.view.icon_parent, { ["src"] = "img_minimap__greenpoint", ["atlas"] = "Atlas/UIMapPanel.spriteatlas", ["a"] = "12" }) end GUI:setVisible(point, true) GUI:setScale(point, self.iconScale) return point end ---@param point function this:PushRoadPoint(point) GUI:setVisible(point, false) if not self.roadPointStack then self.roadPointStack = Stack:New() end self.roadPointStack:Push(point) end function this:ClearAllRoadPoint() for _, v in pairs(self.showedRoadPoints) do self:PushRoadPoint(v) end table.clear(self.showedRoadPoints) end function this:ShowCurPath() self:ClearAllRoadPoint() local path = SL:GetMetaValue(EMetaVarGetKey.MAP_PATH_POINTS) local index = SL:GetMetaValue(EMetaVarGetKey.MAP_CURRENT_PATH_INDEX) if not path or not path.n then return end for i = index, path.n, 4 do local p = path.list[i] local point = self:PopRoadPoint() GUI:setPosition(point, p.x / 256 * self.sceneImgWidth, p.z / 256 * self.sceneImgHeight) self.showedRoadPoints[i] = point end end function this:OnPlayerMapPosChange() local index = SL:GetMetaValue(EMetaVarGetKey.MAP_CURRENT_PATH_INDEX) index = index or 0 for i = 1, index do local point = self.showedRoadPoints[i] if point then self:PushRoadPoint(point) self.showedRoadPoints[i] = nil end end self:RefreshPlayerIconPos() ---使用了随机传送 if self.isUseDelivery then self.isUseDelivery = false --再次寻路 self.DeliveryTimer = SL:Schedule(self.DeliveryTimer, 0, 0.1, -1, function() self:ShowCurPath() end) end end function this:ShowPlayerIcon() self:RefreshPlayerIconPos() self:OnPlayerTurnDir(_, SL:GetMetaValue(EMetaVarGetKey.DIR)) end function this:RefreshPlayerIconPos() ---@type Dot2 local pos = SL:GetMetaValue(EMetaVarGetKey.MAP_PLAYER_POS) local x = pos.x / 256 * self.sceneImgWidth - self.sceneImgWidth / 2 local z = pos.z / 256 * self.sceneImgHeight - self.sceneImgHeight / 2 GUI:setPosition(self.view.img_player_icon, x, z) end function this:OnPlayerTurnDir(_, dir) GUI:setRotation(self.view.img_player_icon, (dir + 1) * -45) end function this:SliderMapSizeOnEvent(_, _, value) local scale = value[1] self:ZoomMap(scale) end function this:ZoomMap(scale) GUI:setScale(self.view.panel_scene, scale * self.initMapScale) self.iconScale = 1 / (scale * self.initMapScale) for _, icon in pairs(self.iconMap) do GUI:setScale(icon.view.root, self.iconScale) end for _, point in pairs(self.showedRoadPoints) do GUI:setScale(point, self.iconScale) end GUI:setScale(self.view.img_player_icon, self.iconScale) if next(self.monsterPointTempList) then for _, v in pairs(self.monsterPointTempList) do v:setScale(1 / GUI:getScale(self.view.panel_scene)) end end end function this:BtnMapZoomInOnClick() local percent = GUI:Slider_getPercent(self.view.slider_map_size) percent = percent + 0.2 if percent > 2 then percent = 2 end GUI:Slider_setPercent(self.view.slider_map_size, percent) self:ZoomMap(percent) end function this:BtnMapZoomOutOnClick() local percent = GUI:Slider_getPercent(self.view.slider_map_size) percent = percent - 0.2 if percent < 1 then percent = 1 end GUI:Slider_setPercent(self.view.slider_map_size, percent) self:ZoomMap(percent) end function this:TransferToShopNpc() local desc = "是否传送至奇迹币宝箱商城?" GUI:UIPanel_Open("dev/ui/Common/Panel/KLUICommonTips/KLUICommonTipsPanel", nil, nil, { showTips = desc, callback = function() self:BtnCloseOnClick() SL:SendTransferToNpcMessage(100115, true) end, callbackData = nil, ui = self }) end --------------------大地图怪点------------------------- function this:ShowMonsterPoint(message) for _, v in pairs(self.monsterPointTempList) do self.MonsterPointPool:Push(v) end self.monsterPointTempList = {}---temp列表保存 local monsterPoints = message.monsterStatus for i, v in pairs(monsterPoints) do if v.groupId ~= 0 then local monsterTbl = SL:GetConfig("cfg_monster", v.configId) local mongenTbl = SL:GetConfig("cfg_mongen", v.groupId) if monsterTbl and (monsterTbl.monsterShowIcon == 1 or monsterTbl.monsterShowName == 1 or monsterTbl.monsterShowLv == 1) then if (mongenTbl and mongenTbl.headpic == 1) or not next(mongenTbl) then local x, y = 0 x = v.pointX / 256 * self.sceneImgWidth - self.sceneImgWidth / 2 y = v.pointY / 256 * self.sceneImgHeight - self.sceneImgHeight / 2 local monsterPointTemp = self.MonsterPointPool:Pop() if not next(monsterPointTemp) then monsterPointTemp = GUI:UIPanel_Open("dev/ui/Map/Item/KLMapMonsterPoint/KLMapMonsterPointItem", self.view.icon_parent, self, nil, true) end self.monsterPointTempList[v.monsterId] = monsterPointTemp monsterPointTemp:ShowBigMonsterIcon(v) monsterPointTemp:SetPanelXY(x, y) monsterPointTemp:SetPanelRotation(0) monsterPointTemp:setScale(1 / GUI:getScale(self.view.panel_scene)) if v.status == 0 then monsterPointTemp:SetDead() else monsterPointTemp:SetLive() end end end end end end ---@param message MapProtos.MapMonsterStatus function this:ResMapMonsterStatusMessage(_, message) if message then self:ShowMonsterPoint(message) end end --[[---设置当前地图中死亡的怪物状态 ---@param message MapProtos.MonsterStatus[] function this:MakeBigMapDeadMonsterIcon(message) for _, v in pairs(self.specialMonsterPointTempList) do v:SetActiveUI(false) self.specialMonsterPointPool:Push(v) end self.specialMonsterPointTempList = {}---temp列表保存 for i, v in pairs(message) do if v.configId == 10008 then self:CreateSpecialMonsterIcon(v) else self:SetMonsterIcon(v) end end end ---刷新地图怪点 ---@param message MapProtos.MonsterStatus function this:SetMonsterIcon(message) if self.monsterPointTempList[message.groupId] then self.monsterPointTempList[message.groupId]:SetActiveUI(true) if message.status == 0 then self.monsterPointTempList[message.groupId]:SetDead() else self.monsterPointTempList[message.groupId]:SetLive() end end end ---刷新地图怪点 ---@param message MapProtos.MonsterStatus function this:SetSpecialMonsterIcon(message) if self.specialMonsterPointTempList[message.monsterId] then self.specialMonsterPointTempList[message.monsterId]:SetActiveUI(true) if message.status == 0 then self.specialMonsterPointTempList[message.monsterId]:SetDead() else self.specialMonsterPointTempList[message.monsterId]:SetLive() end end end ---刷新地图怪点 ---@param message MapProtos.MonsterStatus function this:CreateSpecialMonsterIcon(message) ----@type cfg_monster_attack_column[] local cfg_monster_attackList =SL:GetConfigTable('cfg_monster_attack') if cfg_monster_attackList then local cfg_monster_attack = nil for k,v in pairs(cfg_monster_attackList) do if v.monid == message.configId then cfg_monster_attack = v break end end if cfg_monster_attack then local point = {[1] = message.pointX,[2] = message.pointY} local x, y = 0 if table.count(point) > 1 then x = point[1]/256*self.sceneImgWidth - self.sceneImgWidth/2 y = point[2]/256*self.sceneImgHeight - self.sceneImgHeight/2 end ----@type KLMapMonsterPointItem local monsterPointTemp = self.specialMonsterPointPool:Pop() if not next(monsterPointTemp) then monsterPointTemp = GUI:UIPanel_Open("dev/ui/Map/Item/KLMapMonsterPoint/KLMapMonsterPointItem", self.view.icon_parent, self, nil, true) end --if not string.contains(monsterPointTemp.view.root.kmlControl.rectTransform.name,monsterPointTemp.panelName) then -- SL:LogError("dddddddddddddddddddddddd") --end self.specialMonsterPointTempList[message.monsterId] = monsterPointTemp monsterPointTemp:ShowBigMonsterIcon(cfg_monster_attack) monsterPointTemp:SetPanelXY(x, y) monsterPointTemp:SetPanelRotation(0) monsterPointTemp:setScale(1) monsterPointTemp:SetActiveUI(false) end end self:SetSpecialMonsterIcon(message) end]] return this