DropItemInOfViewCommand.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. local DropItemInOfViewCommand = class('DropItemInOfViewCommand', framework.SimpleCommand)
  2. local proxyUtils = requireProxy( "proxyUtils" )
  3. function DropItemInOfViewCommand:ctor()
  4. end
  5. function DropItemInOfViewCommand:execute(notification)
  6. local data = notification:getBody()
  7. local actorID = data.actorID
  8. local name = data.itemName
  9. local color = data.color or 255
  10. local count = data.count
  11. if count and count > 1 then
  12. name = name .. "x" .. count
  13. end
  14. local actor = global.actorManager:GetActor( actorID )
  15. if not actor then
  16. return
  17. end
  18. actor:SetKeyValue("InView", true)
  19. SetActorAttrByID( actorID, global.MMO.ACTOR_ATTR_PICK, true )
  20. -- hud
  21. local hudParam = {}
  22. hudParam.Name = name
  23. hudParam.Color = string.gsub(GET_COLOR_BYID(color), "#", "0x") or global.MMO.DefaultColor
  24. SetActorName(actor, hudParam)
  25. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actor:GetID(), hudParam = hudParam } )
  26. local pickEnable = proxyUtils:AutoPickItemEnable( actor, nil )
  27. if pickEnable then
  28. local autoProxy = global.Facade:retrieveProxy( global.ProxyTable.Auto )
  29. autoProxy:SetPickItemFlag( true )
  30. end
  31. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  32. local typeIndex = actor:GetTypeIndex()
  33. local guangzhu,front = ItemConfigProxy:GetItemGuangZhu(typeIndex)
  34. if tonumber(guangzhu) and tonumber(guangzhu) > 0 then
  35. local data =
  36. {
  37. actorID = actorID,
  38. sfxID = tonumber(guangzhu),
  39. frame = 0,
  40. speed = 1,
  41. count = 0,
  42. front = front,
  43. }
  44. global.ActorEffectManager:AddEffect(data)
  45. end
  46. if data.jipin == 1 then
  47. local data =
  48. {
  49. actorID = actorID,
  50. sfxID = global.MMO.SFX_DROP_ITEM_JP,
  51. frame = 0,
  52. speed = 1,
  53. count = 0,
  54. front = true,
  55. }
  56. global.ActorEffectManager:AddEffect(data)
  57. end
  58. -- 默认闪光特效
  59. local data =
  60. {
  61. actorID = actorID,
  62. sfxID = global.MMO.SFX_DROP_ITEM_NORAML,
  63. frame = 0,
  64. speed = 1,
  65. count = 0,
  66. front = true,
  67. }
  68. global.ActorEffectManager:AddEffect(data)
  69. end
  70. return DropItemInOfViewCommand