ActorInOfViewCommand.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. local ActorInOfViewCommand = class('ActorInOfViewCommand', framework.SimpleCommand)
  2. local optionsUtils = requireProxy("optionsUtils")
  3. function ActorInOfViewCommand:ctor()
  4. end
  5. function ActorInOfViewCommand:execute(notification)
  6. local data = notification:getBody()
  7. local actor = data.actor
  8. if not actor then
  9. return
  10. end
  11. local actorID = actor:GetID()
  12. local hudParam = data.hudParam
  13. -- hud
  14. self:setActorHUD(actor, actorID, hudParam)
  15. if actor:IsMonster() then
  16. self:onMonsterInOfView(actor, actorID, hudParam)
  17. global.actorInViewController:AddActor(actor)
  18. optionsUtils:InitHUDVisibleValue(actor, global.MMO.MONSTER_NORMAL)
  19. optionsUtils:InitHUDVisibleValue(actor, global.MMO.MONSTER_CLEAR)
  20. elseif actor:IsPlayer() then
  21. self:onPlayerInOfView(actor, actorID, hudParam)
  22. global.actorInViewController:AddActor(actor)
  23. if actor:IsHumanoid() then
  24. optionsUtils:InitHUDVisibleValue(actor, global.MMO.MONSTER_NORMAL)
  25. optionsUtils:InitHUDVisibleValue(actor, global.MMO.MONSTER_CLEAR)
  26. end
  27. elseif actor:IsNPC() then
  28. self:onNPCInOfView(actor, actorID, hudParam)
  29. end
  30. end
  31. function ActorInOfViewCommand:setActorHUD(actor, actorID, hudParam)
  32. SetActorName(actor, hudParam)
  33. SetActorAttrByID(actorID, global.MMO.ACTOR_ATTR_HUDICONS, hudParam.icons)
  34. SetActorAttrByID(actorID, global.MMO.ACTOR_ATTR_HUDTITLE, hudParam.title)
  35. global.Facade:sendNotification(global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actorID, hudParam = hudParam })
  36. global.Facade:sendNotification(global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actorID, hudParam = hudParam })
  37. end
  38. function ActorInOfViewCommand:onPlayerInOfView(actor, actorID, jsonData)
  39. -- 外观
  40. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, jsonData)
  41. jsonData.actor = actor
  42. jsonData.actorID = jsonData.UserID
  43. global.Facade:sendNotification(global.NoticeTable.DelayActorFeatureChange, jsonData)
  44. -- 摆摊
  45. -- 摆摊状态 (0, 1)
  46. actor:SetSellStatus((jsonData.stallname and jsonData.stallname ~= "") and 1 or 0)
  47. actor:SetStallName(jsonData.stallname)
  48. if actorID == global.gamePlayerController:GetMainPlayerID() then
  49. local StallProxy = global.Facade:retrieveProxy(global.ProxyTable.StallProxy)
  50. StallProxy:SetMyTradingStatus(actor:IsStallStatus())
  51. end
  52. global.Facade:sendNotification(global.NoticeTable.Layer_StallLayer_StatusChange, { status = actor:IsStallStatus(), userid = actorID })
  53. global.Facade:sendNotification(global.NoticeTable.PlayerStallStatucChange, { actorID = actorID, actor = actor })
  54. global.Facade:sendNotification(global.NoticeTable.RefreshActorBooth, { actorID = actorID, actor = actor })
  55. end
  56. function ActorInOfViewCommand:onMonsterInOfView(actor, actorID, jsonData)
  57. -- 进视野提醒
  58. local value = CHECK_SETTING(global.MMO.SETTING_IDX_BOSS_TIPS)--总开关
  59. local enable = value == 1
  60. local name = actor:GetName()
  61. local tipsData = CHECK_SETTING_BOSSTIPS(name)
  62. if enable and tipsData and tipsData[2] == 1 and not actor:IsDie() and not actor:IsDeath() then
  63. local mapX = actor:GetMapX()
  64. local mapY = actor:GetMapY()
  65. local MonsterType = tipsData[3] or ""
  66. local MapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  67. local mapID = MapProxy:GetMapID()
  68. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  69. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  70. local dir = mainPlayer and inputProxy:calcMapDirection(cc.p(mapX, mapY), cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())) or 3
  71. local str = string.format(GET_STRING(30103100), mapID, mapX, mapY, MonsterType, name, GET_STRING(30103101 + dir), mapX, mapY)
  72. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  73. local mdata = {
  74. Msg = str,
  75. FColor = 249,
  76. BColor = 255,
  77. ChannelId = ChatProxy.CHANNEL.System,
  78. mt = ChatProxy.MSG_TYPE.SystemTips
  79. }
  80. global.Facade:sendNotification(global.NoticeTable.AddChatItem, mdata)
  81. end
  82. -- collection
  83. if actor:IsCollection() then
  84. self:onCollectionInOfView(actor, actorID)
  85. end
  86. if actor:IsHaveMaster() then
  87. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actorID } )
  88. end
  89. end
  90. function ActorInOfViewCommand:onNPCInOfView(actor, actorID, jsonData)
  91. global.Facade:sendNotification(global.NoticeTable.NpcInOfView, actor:GetID())
  92. end
  93. function ActorInOfViewCommand:onCollectionInOfView(actor, actorID)
  94. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  95. inputProxy:AddCollectCount()
  96. global.Facade:sendNotification(global.NoticeTable.ActorCollect, { actor = actor, sfxID = global.MMO.SFX_MINE })
  97. global.Facade:sendNotification(global.NoticeTable.CollectVisible, true)
  98. end
  99. return ActorInOfViewCommand