| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- SceneMap = {}
- local this = {}
- SceneMap.viewKey = {
- -- VIP数据
- VIP_LV = "vipLv",
- KUN_DUN_FACTION = "kunDunFaction",
- DEMON_HERMIT_SKILL = "demonHermitSkill",
- }
- --- 指定坐标是否为阻挡点 地图ID可不填 (T-非阻挡点, F-阻挡点)
- function SceneMap.notBlockPoint(actor, map_x, map_y, map_id)
- return this.notBlockPoint(actor, map_x, map_y, map_id)
- end
- --- 传送到指定地图
- function SceneMap.doTransfer(actor, map_id, map_line, map_x, map_y, range)
- this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
- end
- --- 玩家进入视野发送全量消息(发送玩家进入视野)
- function SceneMap.playerEnterView(actor, target)
- local s, e = xpcall(this.playerEnterView, debug.traceback, actor, target)
- gameDebug.assertPrint(s, "外置玩家进入视野同步信息异常!", e)
- end
- --- 发送单个信息(更新给周围玩家视野内容变动)
- function SceneMap.sendEnterViewInfoByType(actor, ...)
- this.sendRangeViewChange(actor, ...)
- end
- -- ----------------------------------------------------------------- --
- function this.notBlockPoint(actor, map_x, map_y, map_id)
- if map_id == nil then
- return notblockpoint(actor, map_x, map_y)
- end
- return notblockpoint(actor, map_x, map_y, map_id)
- end
- function this.isBlockPoint(actor, map_x, map_y, map_id)
- return not this.notBlockPoint(actor, map_x, map_y, map_id)
- end
- function this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
- maptransfer(actor, map_x, map_y, map_id, map_line, range)
- end
- function this.playerEnterView(actor, target)
- local data = {}
- data.rid = target:toString()
- gameDebug.print("玩家进入视野同步信息:", "actor", actor, "target", target)
- data[SceneMap.viewKey.VIP_LV] = VipGiftPack.getVipLv(target)
- if KunDun.isInKunDun(target) then
- data[SceneMap.viewKey.KUN_DUN_FACTION] = KunDun.getKunDunViewData(target)
- end
- data[SceneMap.viewKey.DEMON_HERMIT_SKILL] = getplaydef(target, PlayerDefKey.skill.DEMON_HERMIT_SKILL)
- -- 发送通知
- sendluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
- end
- function this.sendRangeViewChange(actor, ...)
- -- 参数必须是偶数
- local args = {...}
- if #args % 2 > 0 then
- return
- end
- local data = {}
- data.rid = actor:toString()
- -- 解析参数
- for i = 1, #args, 2 do
- local type = args[i]
- local param = args[i + 1]
- data[type] = param
- end
- sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
- end
- -- ----------------------------------------------------------------- --
- MapMoveTransfer = {}
- --- MapMove传送
- function MapMoveTransfer.mapMove(actor, move_id)
- this.doMapMove(actor, move_id)
- end
- function MapMoveTransfer.mapMoveWithLine(actor, move_id, line)
- this.doMapMove(actor, move_id, line)
- end
- function this.doMapMove(actor, move_id, line)
- local canTransfer, strTip = LineManager.CheckCanEnterLineMap(actor, tonumber(move_id))
- if not canTransfer then
- tipinfo(actor, strTip)
- return
- end
- if line == nil then
- kmlmapmove(actor, move_id)
- return
- end
- kmlmapmove(actor, move_id, line)
- end
- --- 请求地图内定点传送
- function MapMoveTransfer.transferWithinMap(actor, msgData)
- this.transferWithinMap(actor, msgData)
- end
- function this.transferWithinMap(actor, msgData)
- if table.isEmpty(msgData) then
- return
- end
- if DuplicateCommon.IsInDuplicate(actor) then
- tipinfo(actor, "当前地图不可使用")
- return
- end
- local map_x = tonumber(msgData[1])
- local map_y = tonumber(msgData[2])
- if this.isBlockPoint(actor, map_x, map_y) then
- tipinfo(actor, "目标地点无法抵达")
- return
- end
- local map_id = getbaseinfo(actor, "mapid")
- local line = getbaseinfo(actor, "line")
- local range = 1
- local cost_map = {}
- local cost_str = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.TRANSFER_WITHIN_MAP)
- if not string.isNullOrEmpty(cost_str) then
- string.putIntIntMap(cost_map, cost_str, "#", "|")
- end
- if not table.isNullOrEmpty(cost_map) then
- if not Bag.checkCostMap(actor, cost_map) then
- tipinfo(actor, "道具不足")
- return
- end
- Bag.costMap(actor, cost_map)
- end
- this.doTransfer0(actor, map_id, line, map_x, map_y, range)
- end
- --- 发送单个信息(更新给周围玩家视野内容变动)
- function MapMoveTransfer.transferToMapSelect(actor, msgData)
- this.transferToMapSelect(actor, msgData)
- end
- function this.transferToMapSelect(actor, msgData)
- ---@type cfg_mapMove_column
- local configMapMove = ConfigDataManager.getById("cfg_mapMove", 1101)
- if configMapMove == nil then
- return
- end
- if msgData == nil or msgData.mapId == nil or msgData.itemNeedIndex == nil then
- tipinfo(actor, "请求参数错误")
- return
- end
- local mapId = tonumber(msgData.mapId)
- local canTransfer, strTip = LineManager.CheckCanEnterLineMap(actor, mapId)
- if not canTransfer then
- tipinfo(actor, strTip)
- return
- end
- canTransfer, strTip = LineManager.CheckEnterLineMapItemsNeed(actor, mapId, msgData.itemNeedIndex)
- if not canTransfer then
- tipinfo(actor, strTip)
- return
- end
- local transPointId = -1
- if msgData.transPointId ~= nil then
- transPointId = tonumber(msgData.transPointId)
- end
- local transferPos = { [1] = 24, [2] = 73 }
- if transPointId > 0 then
- local transPoint = ConfigDataManager.getTableValue("cfg_transfer_point", "targetPosition", "id", transPointId)
- if transPoint ~= nil and transPoint ~= "" then
- local tmpTransferPos = string.split(transPoint, "#")
- transferPos = { [1] = tonumber(tmpTransferPos[1]), [2] = tonumber(tmpTransferPos[2]) }
- end
- elseif configMapMove.poz ~= nil and configMapMove.poz ~= "" then
- local tmpTransferPosArr = string.split(configMapMove.poz, "|")[1]
- local tmpTransferPos = string.split(tmpTransferPosArr, "#")
- transferPos = { [1] = tonumber(tmpTransferPos[1]), [2] = tonumber(tmpTransferPos[2]) }
- end
- this.doTransfer0(actor, mapId, 1, transferPos[1], transferPos[2], tonumber(configMapMove.range))
- end
|