RefreshActorIForceCommand.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. local RefreshActorIForceCommand = class('RefreshActorIForceCommand', framework.SimpleCommand)
  2. function RefreshActorIForceCommand:ctor()
  3. end
  4. function RefreshActorIForceCommand:execute(notification)
  5. local data = notification:getBody()
  6. local actorID = data.actorID
  7. local force = data.curInternalForce
  8. local maxForce = data.maxInternalForce
  9. local propertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  10. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  11. local HeroPropertyProxy = global.Facade:retrieveProxy( global.ProxyTable.HeroPropertyProxy )
  12. local HeroID = HeroPropertyProxy:GetRoleUID()
  13. if mainPlayerID == actorID then
  14. if force or maxForce then
  15. propertyProxy:SetIForceData(force, maxForce)
  16. end
  17. elseif HeroID == actorID then
  18. if force or maxForce then
  19. HeroPropertyProxy:SetIForceData(force, maxForce)
  20. end
  21. end
  22. -- refresh hud bar
  23. local actor = global.actorManager:GetActor( actorID )
  24. if actor and (actor:IsPlayer() or actor:IsHero()) then
  25. if actor.SetNGHUD then
  26. actor:SetNGHUD(force, maxForce)
  27. end
  28. end
  29. end
  30. return RefreshActorIForceCommand