SceneImprisonEffectProxy.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --[[
  2. author:yzy
  3. time:2021-03-12 14:28:06
  4. ]]
  5. local RemoteProxy = requireProxy( "remote/RemoteProxy" )
  6. local SceneImprisonEffectProxy = class( "SceneImprisonEffectProxy", RemoteProxy )
  7. SceneImprisonEffectProxy.NAME = global.ProxyTable.SceneImprisonEffectProxy
  8. function SceneImprisonEffectProxy:ctor()
  9. SceneImprisonEffectProxy.super.ctor( self )
  10. self._effect_imprison = {}
  11. end
  12. --检测禁锢
  13. function SceneImprisonEffectProxy:CheckImprison(x,y)
  14. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  15. if global.BuffManager:IsHaveOneBuff(mainPlayerID, global.MMO.BUFF_ID_UN_IMPRISON) then --已经有了防禁锢buff
  16. return false
  17. end
  18. local player = global.gamePlayerController:GetMainPlayer()
  19. local playerMapX, playerMapY = player:GetMapX(), player:GetMapY()
  20. for _,data in pairs(self._effect_imprison) do
  21. local rect = {x=data.cPoint.x, y = data.cPoint.y, width = data.range, height = data.range}
  22. if math.abs( rect.x - playerMapX ) < rect.width and math.abs( rect.y - playerMapY ) < rect.height then --在框内
  23. if ( math.abs(x - rect.x) >= rect.width ) or ( math.abs(y - rect.y) >= rect.height ) then
  24. return true
  25. end
  26. else
  27. if ( math.abs(x - rect.x) < rect.width) and ( math.abs(y - rect.y) < rect.height ) then
  28. return true
  29. end
  30. end
  31. end
  32. return false
  33. end
  34. function SceneImprisonEffectProxy:AddImprison(data)
  35. if data and data.eventID then
  36. self._effect_imprison[data.eventID] = data
  37. end
  38. end
  39. function SceneImprisonEffectProxy:RmImprison(event_id)
  40. if event_id then
  41. self._effect_imprison[event_id] = nil
  42. end
  43. end
  44. function SceneImprisonEffectProxy:handle_MSG_SM_DURANCE_RESPONSE(msg)
  45. local msgHdr = msg:GetHeader()
  46. local nRecog = msgHdr.recog
  47. local msgLen = msg:GetDataLength()
  48. if msgLen > 0 then
  49. local dataString = msg:GetData():ReadString(msgLen)
  50. nRecog = tonumber(dataString)
  51. end
  52. local data = {}
  53. data.eventID = nRecog
  54. data.cPoint = {x = msgHdr.param1, y = msgHdr.param2}
  55. data.range = msgHdr.param3
  56. self:AddImprison( data )
  57. end
  58. function SceneImprisonEffectProxy:onRegister()
  59. local msgType = global.MsgType
  60. LuaRegisterMsgHandler( msgType.MSG_SM_DURANCE_RESPONSE, handler( self, self.handle_MSG_SM_DURANCE_RESPONSE ) )
  61. SceneImprisonEffectProxy.super.onRegister( self )
  62. end
  63. return SceneImprisonEffectProxy