SceneMap.lua 4.2 KB

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