RefreshActorShaBaKeZoneCommand.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. local RefreshActorShaBaKeZoneCommand = class('RefreshActorShaBaKeZoneCommand', framework.SimpleCommand)
  2. function RefreshActorShaBaKeZoneCommand:ctor()
  3. end
  4. function RefreshActorShaBaKeZoneCommand:execute(notification)
  5. local actorID = notification:getBody()
  6. if not actorID then
  7. return nil
  8. end
  9. local actor = global.actorManager:GetActor(actorID)
  10. if not actor then
  11. return nil
  12. end
  13. -- 是否检测区域
  14. local MapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  15. if not MapProxy:IsCheckShaBaKeZone() then
  16. return nil
  17. end
  18. -- 计算状态
  19. local lastShaBaKeZone = actor:GetShaBaKeZone()
  20. local inShaBaKeZone = MapProxy:CheckShaBeKeZone(actor:GetMapX(), actor:GetMapY())
  21. actor:SetShaBaKeZone(inShaBaKeZone)
  22. -- 与上次不同
  23. if lastShaBaKeZone ~= inShaBaKeZone then
  24. global.Facade:sendNotification(global.NoticeTable.DelayRefreshHUDLabel, {
  25. actor = actor,
  26. actorID = actorID
  27. })
  28. end
  29. end
  30. return RefreshActorShaBaKeZoneCommand