WorldBossData.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. local WorldBossData = class("WorldBossData", require("DataBase"))
  2. local CreateActorSystem = require("CreateActorSystem")
  3. local SelfActorSystem = require("SelfActorSystem")
  4. local BossListRequestInterval = 1000
  5. local ChallengeBossRequestInterval = 1000
  6. function WorldBossData:ctor()
  7. self.worldBossCount = nil -- 世界bosss剩余挑战次数
  8. self.worldBossLs = nil -- 世界boss列表 (只在UI界面中显示的Boss列表)
  9. self.lastBossListRequestTime = nil -- 上一次boss列表请求时间
  10. self.lastChallengeBossRequestTime = nil
  11. end
  12. function WorldBossData:Clear()
  13. self.worldBossLs = nil
  14. self.lastBossListRequestTime = nil
  15. self.lastChallengeBossRequestTime = nil
  16. self:ExitWorldBossBattle()
  17. end
  18. function WorldBossData:Destroy()
  19. if self.Clear then
  20. self:Clear()
  21. end
  22. self:UnRegisterNetEvents()
  23. end
  24. function WorldBossData:ClearActorData()
  25. if nil ~= self.selfActorSystem then
  26. --self.selfActorSystem:Dispose()
  27. self.selfActorSystem = {}
  28. end
  29. if nil ~= self.actorSystems then
  30. for i=1, #self.actorSystems do
  31. self.actorSystems[i]:Dispose()
  32. end
  33. self.actorSystems = {}
  34. end
  35. end
  36. function WorldBossData:RegisterNetEvents()
  37. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_ROLE_MAP_CHANGE_NTF, self.ResponseWorldBossCountNtf, self)
  38. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_WORLD_BOSS_LIST_ACK, self.ResponseWorldBossListAck, self)
  39. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_CHALLENGE_SUMMON_ACK, self.ResponseChallengeBossAck, self)
  40. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_CHALLENGE_SUMMON_NTF, self.ResponseChallengeBossNtf, self)
  41. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_CHALLENGE_HP_NTF, self.ResponseChallengeHpNtf, self)
  42. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_LEAVE_CHALLENGE_NTF, self.ResponseChallengeLeaveNtf, self)
  43. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_CHALLENGE_RESULT_NTF, self.ResponseChallengeResultNtf, self)
  44. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_WORLD_BOSS_RAND_NTF, self.ResponseWorldBossRandNtf, self)
  45. end
  46. function WorldBossData:UnRegisterNetEvents()
  47. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_ROLE_MAP_CHANGE_NTF)
  48. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_WORLD_BOSS_LIST_ACK)
  49. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_CHALLENGE_SUMMON_ACK)
  50. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_CHALLENGE_SUMMON_NTF)
  51. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_CHALLENGE_HP_NTF)
  52. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_LEAVE_CHALLENGE_NTF)
  53. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_CHALLENGE_RESULT_NTF)
  54. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_WORLD_BOSS_RAND_NTF)
  55. end
  56. function WorldBossData:ResponseWorldBossCountNtf(data)
  57. LogError("[Wboy] SC_ROLE_MAP_CHANGE_NTF " .. Inspect(data))
  58. if ManagerContainer.NetManager:IsErrorData(data) then
  59. return
  60. end
  61. self:ChangeWorldBossCount(data.world_boss_count)
  62. end
  63. function WorldBossData:ResponseWorldBossListAck(data)
  64. LogError("[Wboy] CS_PLAYER_WORLD_BOSS_LIST_ACK " .. Inspect(data))
  65. if ManagerContainer.NetManager:IsErrorData(data) then
  66. return
  67. end
  68. local worldBossList = data.world_boss_list
  69. local worldBossLs = {}
  70. for i = 1, #worldBossList do
  71. local infoData = ProtocalDataNormal.ParseWorldBossContentInfoData(worldBossList[i])
  72. if infoData then
  73. worldBossLs[#worldBossLs + 1] = infoData
  74. end
  75. end
  76. table.sort(worldBossLs, function(a, b)
  77. local A = 10000 * a.boss_summon_type - a.bossId
  78. local B = 10000 * b.boss_summon_type - b.bossId
  79. return A > B
  80. end)
  81. self.worldBossLs = worldBossLs
  82. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_LIST_CHANGED)
  83. end
  84. function WorldBossData:ResponseChallengeBossAck(data)
  85. --LogError("[Wboy] SC_PLAYER_CHALLENGE_SUMMON_ACK " .. Inspect(data))
  86. if ManagerContainer.NetManager:IsErrorData(data) then
  87. -- 更新数据
  88. local infoData = ProtocalDataNormal.ParseWorldBossContentInfoData(data.boss_info)
  89. local changed = false
  90. if infoData then
  91. if self.worldBossLs then
  92. for i = 1, #self.worldBossLs do
  93. local item = self.worldBossLs[i]
  94. if infoData.bossId == item.bossId and infoData.bossSummonIdx == item.bossSummonIdx then
  95. self.worldBossLs[i] = infoData
  96. changed = true
  97. break
  98. end
  99. end
  100. end
  101. end
  102. if changed then
  103. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_LIST_CHANGED)
  104. end
  105. -- self:SendWorldBossListRequest()
  106. end
  107. end
  108. function WorldBossData:ResponseChallengeBossNtf(data)
  109. -- LogError("[Wboy] SC_PLAYER_CHALLENGE_SUMMON_NTF " .. Inspect(data))
  110. if ManagerContainer.NetManager:IsErrorData(data) then
  111. return
  112. end
  113. local uid = data.self_uid
  114. local fighters = data.fight_list
  115. local bossId = data.boss_uid
  116. local ChangePetId = data.self_change_play_id
  117. local BossType = data.summon_boss_type
  118. bossId = type(bossId) == "number" and bossId or #bossId
  119. local isSelf = (uid == ManagerContainer.DataMgr.UserData:GetUserId())
  120. local actorSystems = {}
  121. if fighters then
  122. for i = 1, #fighters do
  123. local fighter = fighters[i]
  124. if fighters then
  125. local actorSystem = CreateActorSystem:new()
  126. if nil ~= actorSystem then
  127. actorSystem:ParseFightRoleInfo(fighter)
  128. actorSystems[#actorSystems + 1] = actorSystem
  129. end
  130. end
  131. end
  132. end
  133. if isSelf then
  134. self:EnterWorldBossBattle(uid, bossId, actorSystems,ChangePetId,BossType)
  135. else
  136. -- 其它玩家进入挑战boss
  137. self:OtherEnterWorldBossBattle(uid, bossId, actorSystems,ChangePetId,BossType)
  138. end
  139. end
  140. function WorldBossData:ResponseChallengeHpNtf(data)
  141. -- LogError("[Wboy] SC_PLAYER_CHALLENGE_HP_NTF " .. Inspect(data))
  142. if ManagerContainer.NetManager:IsErrorData(data) then
  143. return
  144. end
  145. local life = data.cur_boss_hp
  146. self:WorldBossHpChanged(life)
  147. end
  148. function WorldBossData:ResponseChallengeLeaveNtf(data)
  149. -- LogError("[Wboy] SC_PLAYER_LEAVE_CHALLENGE_NTF " .. Inspect(data))
  150. if ManagerContainer.NetManager:IsErrorData(data) then
  151. return
  152. end
  153. local uid = data.uid
  154. self:OtherExitWorldBossBattle(uid)
  155. end
  156. function WorldBossData:ResponseChallengeResultNtf(data)
  157. --LogError("[Wboy] SC_PLAYER_CHALLENGE_RESULT_NTF " .. Inspect(data))
  158. if ManagerContainer.NetManager:IsErrorData(data) then
  159. return
  160. end
  161. -- 1:胜利;2:超时战斗结束
  162. local result = data.result
  163. self:ForceExitWorldBossBattle(result)
  164. end
  165. function WorldBossData:ResponseWorldBossRandNtf(data)
  166. --LogError("[Wboy] SC_PLAYER_WORLD_BOSS_RAND_NTF " .. Inspect(data))
  167. if ManagerContainer.NetManager:IsErrorData(data) then
  168. self.worldBossPointInfo = nil
  169. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_ROLL_POINT_LIST_CHANGED)
  170. return
  171. end
  172. self.worldBossPointInfo = ProtocalDataNormal.ParseWorldBossRandPointInfoData(data.point_info)
  173. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_ROLL_POINT_LIST_CHANGED)
  174. end
  175. --- 获得世界boss列表
  176. ---@return integer 0:发送成功;1:客户端限制发送
  177. function WorldBossData:SendWorldBossListRequest()
  178. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  179. if self.lastBossListRequestTime ~= nil and (curTime - self.lastBossListRequestTime) < BossListRequestInterval then
  180. return 1
  181. end
  182. self.lastBossListRequestTime = curTime
  183. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_WORLD_BOSS_LIST_REQ, {})
  184. return 0
  185. end
  186. --- 请求挑战boss
  187. ---@param bossId integer
  188. ---@param bossSummonIdx integer
  189. function WorldBossData:SendChallengeBossRequest(bossId, bossSummonIdx)
  190. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  191. if self.lastChallengeBossRequestTime ~= nil and (curTime - self.lastChallengeBossRequestTime) < ChallengeBossRequestInterval then
  192. return 1
  193. end
  194. self.lastChallengeBossRequestTime = curTime
  195. local uid = ManagerContainer.DataMgr.UserData:GetUserId()
  196. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_CHALLENGE_SUMMON_REQ, {uid = uid, challenge_boss_uid = bossId, boss_summon_idx = bossSummonIdx})
  197. return 0
  198. end
  199. function WorldBossData:HasWorldBossList()
  200. return self.worldBossLs ~= nil
  201. end
  202. --- 获得世界boss列表
  203. function WorldBossData:GetWorldBossList()
  204. return self.worldBossLs
  205. end
  206. function WorldBossData:ClearWorldBossList()
  207. self.worldBossLs = nil
  208. end
  209. function WorldBossData:HasWorldBossPointInfo()
  210. return self.worldBossPointInfo ~= nil
  211. end
  212. function WorldBossData:GetWorldBossPointInfo()
  213. return self.worldBossPointInfo
  214. end
  215. function WorldBossData:ClearWorldBossPointInfo()
  216. self.worldBossPointInfo = nil
  217. end
  218. function WorldBossData:GetWorldBossCount()
  219. return self.worldBossCount
  220. end
  221. function WorldBossData:ChangeWorldBossCount(count)
  222. if self.worldBossCount ~= count then
  223. self.worldBossCount = count
  224. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_CHALLENGE_COUNT_CHANGED)
  225. end
  226. end
  227. function WorldBossData:GetWorldBossDataById(bossId,bosstype)
  228. if bosstype > 0 then
  229. return ManagerContainer.CfgMgr:GetWorldPetBossDataById(bossId)
  230. else
  231. return ManagerContainer.CfgMgr:GetWorldBossDataById(bossId)
  232. end
  233. end
  234. -------------------------------------------- 挑战世界boss中的数据 -------------------------------
  235. local MaxPlayerNumSomeTime = 8
  236. --- 世界boss战斗中玩家入场和出场的表现时间 (用于保持战斗和UI在进出时一致)
  237. local WorldBossEnterExitTime = 1
  238. local WorldBossUpLoadTime = 1
  239. function WorldBossData:EnterWorldBossBattle(bossOwnerUid, bossId, actorSystems,ChangePetId,BossType)
  240. -- 避免服务器回两次包,导致重复进入战斗
  241. if self.isBattling then return end
  242. self.bossId = bossId
  243. self.bossOwnerUid = bossOwnerUid
  244. self.actorSystemNum = 0 -- 当前在战场中的人数
  245. self.actorSystemMap = {}
  246. self.lastEnterExitTime = nil
  247. self.defaultInBattleUIds = {} -- 初始的时候就在战斗场景中的玩家
  248. self.preActorSystemInfos = {} -- 进出战斗的玩家队列
  249. self.preActorSystemTimer = Timer.New(function()
  250. self:ExecuteEnterExit()
  251. end, WorldBossEnterExitTime, -1) -- 进出战斗的表现,需要让玩家队列执行
  252. self.totalDamage = 0 -- 在上传伤害的CD中累计的伤害值
  253. self.worldBossUpLoadTimer = Timer.New(function()
  254. self:SendChallengeBossDamageRequest()
  255. end, WorldBossUpLoadTime, -1)
  256. self.curHp = 1
  257. self.maxHp = 1
  258. self.isBattling = nil -- 是否在战斗中
  259. self.isBattleLoading = nil -- 是否在战斗加载中
  260. self.isBattleUIReady = nil -- 是否战斗界面准备好了
  261. local num = #actorSystems
  262. local NextNum = num + 1
  263. local actorArray = System.Array.CreateInstance(Enum.TypeInfo.ActorData, NextNum)
  264. self.selfActorSystem = SelfActorSystem:new()
  265. local uid = self.selfActorSystem:GetUserId()
  266. --是否有变身ID
  267. if nil ~= ChangePetId and ChangePetId > 0 then
  268. self.selfActorSystem:CreatePetBossActor(ChangePetId)
  269. end
  270. actorArray[0] = self.selfActorSystem:GetPlayerActorParam()
  271. actorArray[0].ID = uid
  272. self.defaultInBattleUIds[NextNum] = uid
  273. self.actorSystemMap[uid] = self.selfActorSystem
  274. self.actorSystemNum = self.actorSystemNum + 1
  275. for i = 1, num do
  276. local actorSystem = actorSystems[i]
  277. uid = actorSystem:GetUserId()
  278. --是否有变身ID
  279. if nil ~= actorSystem.userData.change_play_id and actorSystem.userData.change_play_id>0 then
  280. actorSystem:CreatePetBossActor(actorSystem.userData.change_play_id)
  281. end
  282. actorArray[i] = actorSystem:GetPlayerActorParam()
  283. self.defaultInBattleUIds[i] = uid
  284. actorArray[i].ID = uid
  285. self.actorSystemMap[uid] = actorSystem
  286. self.actorSystemNum = self.actorSystemNum + 1
  287. end
  288. -- 启动世界boss的战斗
  289. if ManagerContainer.LuaGameMgr then
  290. self.isBattling = true
  291. self.isBattleLoading = true
  292. local summonId = 0
  293. local summonScene = 0
  294. local worldBossCfgData = self:GetWorldBossDataById(bossId,BossType)
  295. if worldBossCfgData then
  296. summonId = worldBossCfgData.SummonId
  297. summonScene = worldBossCfgData.SummonScence
  298. local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(summonId)
  299. if npcCfgData then
  300. self.curHp = npcCfgData.Hp
  301. self.maxHp = npcCfgData.Hp
  302. end
  303. end
  304. if self.worldBossLs then
  305. -- 找出当前血量
  306. for i = 1, #self.worldBossLs do
  307. local item = self.worldBossLs[i]
  308. if bossId == item.bossId then
  309. self.curHp = item.curHp
  310. self.maxHp = item.totalHp
  311. break
  312. end
  313. end
  314. end
  315. local battleEndCondList = System.Array.CreateInstance(Enum.TypeInfo.BattleEndCondition, 2)
  316. battleEndCondList[0] = BattleEndCondition.New(Constants.EndBattle_By_MainRoleDead,Constants.ResultType_Normal)
  317. battleEndCondList[1] = BattleEndCondition.New(Constants.EndBattle_By_BossDead,Constants.ResultType_Normal)
  318. ManagerContainer.LuaGameMgr:EnterWorldBoss(actorArray, summonId, summonScene,battleEndCondList)
  319. end
  320. end
  321. function WorldBossData:ExitWorldBossBattle()
  322. -- 退出战斗后数据的清理
  323. self:ClearActorData()
  324. self.bossId = nil
  325. self.bossOwnerUid = nil
  326. self.actorSystemNum = nil
  327. self.actorSystemMap = nil
  328. self.lastEnterExitTime = nil
  329. self.defaultInBattleUIds = nil
  330. self.preActorSystemInfos = nil
  331. if self.preActorSystemTimer and self.preActorSystemTimer.running then
  332. self.preActorSystemTimer:Stop()
  333. end
  334. self.preActorSystemTimer = nil
  335. self.totalDamage = nil
  336. if self.worldBossUpLoadTimer and self.worldBossUpLoadTimer.running then
  337. self.worldBossUpLoadTimer:Stop()
  338. end
  339. self.worldBossUpLoadTimer = nil
  340. self.curHp = nil
  341. self.maxHp = nil
  342. self.isBattling = nil
  343. self.isBattleLoading = nil
  344. self.isBattleUIReady = nil
  345. end
  346. function WorldBossData:WorldBossBattleLoadBegin()
  347. self.isBattleLoading = true
  348. end
  349. function WorldBossData:WorldBossBattleLoadComplete()
  350. self.isBattleLoading = false
  351. self:ExecuteEnterExit()
  352. end
  353. function WorldBossData:WorldBossBattleUIReady()
  354. self.isBattleUIReady = true
  355. self:ExecuteEnterExit()
  356. end
  357. function WorldBossData:RecordBossDamage(damage)
  358. if not self.isBattling then return end
  359. if not damage or damage <= 0 then return end
  360. self.totalDamage = self.totalDamage + damage
  361. if not self.worldBossUpLoadTimer then
  362. self:SendChallengeBossDamageRequest()
  363. return
  364. end
  365. if not self.worldBossUpLoadTimer.running then
  366. self:SendChallengeBossDamageRequest()
  367. self.worldBossUpLoadTimer:Start()
  368. end
  369. end
  370. function WorldBossData:SendChallengeBossDamageRequest()
  371. if not self.isBattling then return end
  372. if not self.totalDamage or self.totalDamage <= 0 then return end
  373. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_CHALLENGE_HP_REQ, {damage_hp = self.totalDamage})
  374. self.totalDamage = 0
  375. end
  376. function WorldBossData:SendLeaveChallengeBossRequest()
  377. self:SendChallengeBossDamageRequest()
  378. if not self.isBattling then return end
  379. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_LEAVE_CHALLENGE_REQ, {})
  380. end
  381. function WorldBossData:ForceExitWorldBossBattle(result)
  382. if result == 1 then
  383. -- boss死亡
  384. self:WorldBossHpChanged(0)
  385. end
  386. if not self.isBattling then return end
  387. self.isBattling = false
  388. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_SERVER_KICKOUT_BATTLE, result)
  389. end
  390. function WorldBossData:OtherEnterWorldBossBattle(bossOwnerUid, bossId, actorSystems,ChangePetId,BossType)
  391. if not self.isBattling then return end
  392. if self.bossOwnerUid == bossOwnerUid then return end
  393. if self.bossId ~= bossId then return end
  394. for i = 1, #actorSystems do
  395. local actorSystem = actorSystems[i]
  396. local data = {isEnter = true, data = actorSystem}
  397. table.insert(self.preActorSystemInfos, data)
  398. end
  399. self:ExecuteEnterExit()
  400. end
  401. function WorldBossData:OtherExitWorldBossBattle(uid)
  402. if not self.isBattling then return end
  403. local data = {isEnter = false, data = uid}
  404. table.insert(self.preActorSystemInfos, data)
  405. self:ExecuteEnterExit()
  406. end
  407. function WorldBossData:WorldBossHpChanged(hp)
  408. if not self.isBattling then return end
  409. if self.curHp == hp then return end
  410. self.curHp = hp
  411. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_HP_CHANGED)
  412. end
  413. function WorldBossData:ExecuteEnterExit()
  414. if self.isBattleLoading or not self.isBattling or not self.isBattleUIReady then return end
  415. if self.preActorSystemTimer and self.preActorSystemTimer.running then
  416. return
  417. end
  418. if not self.preActorSystemInfos then return end
  419. local num = #self.preActorSystemInfos
  420. if num <= 0 then return end
  421. local enters = {}
  422. local exits = {}
  423. local index = nil
  424. local uid
  425. --- 找出一段有效数据
  426. for i = 1, num do
  427. local preActorSystemInfo = self.preActorSystemInfos[i]
  428. local isEnter = preActorSystemInfo.isEnter
  429. local data = preActorSystemInfo.data
  430. local vaild = true
  431. if isEnter then
  432. uid = data:GetUserId()
  433. if uid then
  434. for j = 1, #exits do
  435. if uid == exits[j] then
  436. -- 当前玩家正在退出,又要进入,则需要在下次表现时,再处理
  437. vaild = false
  438. break
  439. end
  440. end
  441. if not vaild then break end
  442. -- 进入玩家导致当前场景中玩家数超出上限
  443. if self.actorSystemNum + 1 > MaxPlayerNumSomeTime then break end
  444. if self.actorSystemMap[uid] then
  445. index = i
  446. break
  447. end
  448. self.actorSystemMap[uid] = data
  449. self.actorSystemNum = self.actorSystemNum + 1
  450. table.insert(enters, {uid = uid, data = data})
  451. index = i
  452. end
  453. else
  454. uid = data
  455. if uid then
  456. for j = 1, #enters do
  457. if uid == enters[j].uid then
  458. -- 当前玩家正在进入,又要退出,则需要在下次表现时,再处理
  459. vaild = false
  460. break
  461. end
  462. end
  463. if not vaild then break end
  464. self.actorSystemMap[uid] = nil
  465. self.actorSystemNum = self.actorSystemNum - 1
  466. table.insert(exits, uid)
  467. index = i
  468. end
  469. end
  470. end
  471. if index then
  472. if index >= num then
  473. self.preActorSystemInfos = {}
  474. else
  475. local newInfos = {}
  476. -- table.move(self.preActorSystemInfos, index + 1, num, 1, newInfos)
  477. -- self.preActorSystemInfos = newInfos
  478. for j = index + 1, num do
  479. table.insert(newInfos, self.preActorSystemInfos[j])
  480. end
  481. self.preActorSystemInfos = newInfos
  482. end
  483. else
  484. LogError('[Wboy] Logic error of player entering and exiting in world boss battle !!!')
  485. end
  486. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_BOSS_PLAYER_CHANGED, enters, exits)
  487. if #self.preActorSystemInfos > 0 then
  488. if not self.preActorSystemTimer.running then
  489. self.preActorSystemTimer:Start()
  490. end
  491. else
  492. self.preActorSystemTimer:Stop()
  493. end
  494. end
  495. function WorldBossData:GetCurHp()
  496. return self.curHp
  497. end
  498. function WorldBossData:GetMaxHp()
  499. return self.maxHp
  500. end
  501. function WorldBossData:GetBattleBossId()
  502. return self.bossId
  503. end
  504. function WorldBossData:GetActorSystemByUID(uid)
  505. if uid == nil then return nil end
  506. return self.actorSystemMap[uid]
  507. end
  508. function WorldBossData:GetActorSystem()
  509. return self.actorSystemMap
  510. end
  511. --- 默认进入场景的玩家uid列表
  512. function WorldBossData:GetDefaultInBattleUIds()
  513. return self.defaultInBattleUIds
  514. end
  515. return WorldBossData