SceneMap.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. SceneMap = {}
  2. local this = {}
  3. SceneMap.viewKey = {
  4. -- VIP数据
  5. VIP_LV = "vipLv",
  6. KUN_DUN_FACTION = "kunDunFaction",
  7. }
  8. --- 指定坐标是否为阻挡点 地图ID可不填 (T-非阻挡点, F-阻挡点)
  9. function SceneMap.notBlockPoint(actor, map_x, map_y, map_id)
  10. return this.notBlockPoint(actor, map_x, map_y, map_id)
  11. end
  12. --- 传送到指定地图
  13. function SceneMap.doTransfer(actor, map_id, map_line, map_x, map_y, range)
  14. this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
  15. end
  16. --- 玩家进入视野发送全量消息(发送玩家进入视野)
  17. function SceneMap.playerEnterView(actor, target)
  18. local s, e = xpcall(this.playerEnterView, debug.traceback, actor, target)
  19. gameDebug.assertPrint(s, "外置玩家进入视野同步信息异常!", e)
  20. end
  21. --- 发送单个信息(更新给周围玩家视野内容变动)
  22. function SceneMap.sendEnterViewInfoByType(actor, ...)
  23. this.sendRangeViewChange(actor, ...)
  24. end
  25. -- ----------------------------------------------------------------- --
  26. function this.notBlockPoint(actor, map_x, map_y, map_id)
  27. if map_id == nil then
  28. return notblockpoint(actor, map_x, map_y)
  29. end
  30. return notblockpoint(actor, map_x, map_y, map_id)
  31. end
  32. function this.isBlockPoint(actor, map_x, map_y, map_id)
  33. return not this.notBlockPoint(actor, map_x, map_y, map_id)
  34. end
  35. function this.doTransfer0(actor, map_id, map_line, map_x, map_y, range)
  36. maptransfer(actor, map_x, map_y, map_id, map_line, range)
  37. end
  38. function this.playerEnterView(actor, target)
  39. local data = {}
  40. data.rid = target:toString()
  41. gameDebug.print("玩家进入视野同步信息:", "actor", actor, "target", target)
  42. data[SceneMap.viewKey.VIP_LV] = VipGiftPack.getVipLv(target)
  43. if KunDun.isInKunDun(target) then
  44. data[SceneMap.viewKey.KUN_DUN_FACTION] = KunDun.getKunDunViewData(target)
  45. end
  46. -- 发送通知
  47. sendluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
  48. end
  49. function this.sendRangeViewChange(actor, ...)
  50. -- 参数必须是偶数
  51. local args = {...}
  52. if #args % 2 > 0 then
  53. return
  54. end
  55. local data = {}
  56. data.rid = actor:toString()
  57. -- 解析参数
  58. for i = 1, #args, 2 do
  59. local type = args[i]
  60. local param = args[i + 1]
  61. data[type] = param
  62. end
  63. sendrefluamsg(actor, LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, data)
  64. end
  65. -- ----------------------------------------------------------------- --
  66. MapMoveTransfer = {}
  67. --- MapMove传送
  68. function MapMoveTransfer.mapMove(actor, move_id)
  69. this.doMapMove(actor, move_id)
  70. end
  71. function MapMoveTransfer.mapMoveWithLine(actor, move_id, line)
  72. this.doMapMove(actor, move_id, line)
  73. end
  74. function this.doMapMove(actor, move_id, line)
  75. if line == nil then
  76. kmlmapmove(actor, move_id)
  77. return
  78. end
  79. kmlmapmove(actor, move_id, line)
  80. end
  81. --- 请求地图内定点传送
  82. function MapMoveTransfer.transferWithinMap(actor, msgData)
  83. this.transferWithinMap(actor, msgData)
  84. end
  85. function this.transferWithinMap(actor, msgData)
  86. if table.isEmpty(msgData) then
  87. return
  88. end
  89. if DuplicateCommon.IsInDuplicate(actor) then
  90. tipinfo(actor, "当前地图不可使用")
  91. return
  92. end
  93. local map_x = tonumber(msgData[1])
  94. local map_y = tonumber(msgData[2])
  95. if this.isBlockPoint(actor, map_x, map_y) then
  96. tipinfo(actor, "目标地点无法抵达")
  97. return
  98. end
  99. local map_id = getbaseinfo(actor, "mapid")
  100. local line = getbaseinfo(actor, "line")
  101. local range = 1
  102. local cost_map = {}
  103. local cost_str = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.TRANSFER_WITHIN_MAP)
  104. if not string.isNullOrEmpty(cost_str) then
  105. string.putIntIntMap(cost_map, cost_str, "#", "|")
  106. end
  107. if not table.isNullOrEmpty(cost_map) then
  108. if not Bag.checkCostMap(actor, cost_map) then
  109. tipinfo(actor, "道具不足")
  110. return
  111. end
  112. Bag.costMap(actor, cost_map)
  113. end
  114. this.doTransfer0(actor, map_id, line, map_x, map_y, range)
  115. end