SanctuaryBossInfo.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ---@class SanctuaryBossInfo
  2. ---@field sanctuaryNpcId number
  3. ---@field sanctuaryMapId number
  4. SanctuaryBossInfo = class()
  5. local this = SanctuaryBossInfo
  6. function this:ctor()
  7. end
  8. function this:Reset()
  9. self.sanctuaryNpcId = nil
  10. self.sanctuaryMapId = nil
  11. end
  12. function this:Init()
  13. self:InitData()
  14. self:RegistMessages()
  15. end
  16. function this:InitData()
  17. end
  18. function this:RegistMessages()
  19. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_IN_OUT_CROSS_MAP, self.RES_IN_OUT_CROSS_MAP, self)
  20. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_CROSS_MAP_TRANSFER_TO_NPC, self.RES_CROSS_MAP_TRANSFER_TO_NPC, self)
  21. end
  22. ----进入跨服地图(如果距离NPC很近打开NPC面板)
  23. ---@param message {mapId:number,type:number}
  24. function this:RES_IN_OUT_CROSS_MAP(_, message)
  25. if self.sanctuaryNpcId and message.type == 1 then
  26. --local distance = SL:GetMetaValue(EMetaVarGetKey.NPC_DISTANCE)
  27. --if distance and distance < 2 then
  28. -- SL:TalkToNpc(self.sanctuaryNpcId)
  29. -- self.sanctuaryNpcId = nil
  30. --end
  31. SL:ScheduleOnce(Time.deltaTime, function()
  32. GUI:UIPanel_Open("dev/outui/ChallengeBoss/Panel/KLChallengeBossSanctuaryMap/KLChallengeBossSanctuaryMapPanel")
  33. self.sanctuaryNpcId = nil
  34. end)
  35. end
  36. end
  37. ----进入跨服地图(如果距离NPC很近打开NPC面板)
  38. ---@param message {npc_id:number,map_id:number}
  39. function this:RES_CROSS_MAP_TRANSFER_TO_NPC(_, message)
  40. local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID)
  41. if self.sanctuaryNpcId and message.map_id == tostring(mapId) then
  42. local npcList = SL:GetMetaValue(EMetaVarGetKey.SEE_NPC)
  43. local npcRoleId = nil
  44. for k,v in pairs(npcList) do
  45. if v.data.npcTbl and v.data.npcTbl.id == self.sanctuaryNpcId then
  46. npcRoleId = v.data.id
  47. break
  48. end
  49. end
  50. if npcRoleId then
  51. local distance = SL:GetMetaValue(EMetaVarGetKey.NPC_DISTANCE,npcRoleId)
  52. if distance and distance < 2 then
  53. SL:ScheduleOnce(Time.deltaTime, function()
  54. SL:TalkToNpc(self.sanctuaryNpcId)
  55. self.sanctuaryNpcId = nil
  56. end)
  57. end
  58. end
  59. end
  60. end
  61. function this:GetIsSatisfy()
  62. ---@type cfg_activity_rule_column
  63. local tab = SL:GetConfig("cfg_activity_rule",25001)
  64. ---@type cfg_map_info_column
  65. local mapTab = SL:GetConfig("cfg_map_info",tab.mapid[1])
  66. self.level_lock = false
  67. self.strength_lock = false
  68. self.append_lock = false
  69. self.open_level = 0
  70. if mapTab and #mapTab.condition > 0 then
  71. local condition = mapTab.condition
  72. local level = condition[1]
  73. local strength_level = condition[2]
  74. local append_level = condition[3]
  75. local player_level = SL:GetMetaValue("LEVEL")
  76. local all_strength_level = EquipFunc.GetAllStrengthLevel()
  77. local all_append_level = EquipFunc.GetAllAppendLevel()
  78. if player_level < level then
  79. self.level_lock = true
  80. self.open_level = level
  81. end
  82. if all_strength_level < strength_level then
  83. self.strength_lock = true
  84. end
  85. if all_append_level < append_level then
  86. self.append_lock = true
  87. end
  88. end
  89. if self.level_lock then
  90. return false, self.open_level .. "级开启,无法进入"
  91. end
  92. if self.strength_lock then
  93. return false, SL:GetConfig('cfg_string', 257).text
  94. end
  95. if self.append_lock then
  96. return false, SL:GetConfig('cfg_string', 257).text
  97. end
  98. return true
  99. end