ChangePlayerFeatureCommand.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. local ChangePlayerFeatureCommand = class('ChangePlayerFeatureCommand', framework.SimpleCommand)
  2. function ChangePlayerFeatureCommand:ctor()
  3. end
  4. function ChangePlayerFeatureCommand:execute(notification)
  5. local data = notification:getBody()
  6. if not data then
  7. return false
  8. end
  9. if not data.actorID then
  10. return false
  11. end
  12. local actor = global.actorManager:GetActor(data.actorID)
  13. if not actor then
  14. return false
  15. end
  16. local actorID = actor:GetID()
  17. local feature = TransformFeatureByJson( data )
  18. local mainPlyayerID = global.gamePlayerController:GetMainPlayerID()
  19. if actorID == mainPlyayerID then
  20. self:onChangeMainPlayerFeature( feature )
  21. end
  22. local HeroPropertyProxy = global.Facade:retrieveProxy( global.ProxyTable.HeroPropertyProxy )
  23. local heroID = HeroPropertyProxy:GetRoleUID()
  24. if actorID == heroID then
  25. self:onChangeMainPlayerFeature_Hero( feature )
  26. end
  27. local specialSign = data.show
  28. -- -- 新出的时装与原有发型,头盔斗笠,翅膀不兼容的屏蔽
  29. if specialSign and specialSign > 0 then
  30. feature.hairID = 0
  31. feature.wingsID = 0
  32. feature.capID = 0
  33. end
  34. local fData = clone( feature )
  35. fData.actor = actor
  36. global.Facade:sendNotification( global.NoticeTable.SetPlayerFeature, fData )
  37. global.Facade:sendNotification( global.NoticeTable.RefreshOneActorCloth, actor )
  38. end
  39. function ChangePlayerFeatureCommand:onChangeMainPlayerFeature( feature )
  40. local playerPropertyProxy = global.Facade:retrieveProxy( global.ProxyTable.PlayerProperty )
  41. playerPropertyProxy:SetFeature( feature )
  42. end
  43. function ChangePlayerFeatureCommand:onChangeMainPlayerFeature_Hero( feature )
  44. local HeroPropertyProxy = global.Facade:retrieveProxy( global.ProxyTable.HeroPropertyProxy )
  45. HeroPropertyProxy:SetFeature( feature )
  46. end
  47. return ChangePlayerFeatureCommand