netPlayerController.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. local netActorController = require("logic/netActorController")
  2. local netPlayerController = class("netPlayerController",netActorController)
  3. netPlayerController.NAME = "netPlayerController"
  4. local moveStep =
  5. {
  6. [global.MMO.ACTION_WALK] = 1,
  7. [global.MMO.ACTION_RUN] = 2,
  8. [global.MMO.ACTION_RIDE_RUN] = 3,
  9. }
  10. function netPlayerController:ctor()
  11. netPlayerController.super.ctor(self)
  12. end
  13. function netPlayerController:destory()
  14. netPlayerController.super.ctor(self)
  15. if netPlayerController.instance then
  16. netPlayerController.instance = nil
  17. end
  18. end
  19. function netPlayerController:Inst()
  20. if not netPlayerController.instance then
  21. netPlayerController.instance = netPlayerController.new()
  22. end
  23. return netPlayerController.instance
  24. end
  25. ---------------------------------------------------------------------------
  26. function netPlayerController:handleActionBegin(actor, act, Param1, Param2)
  27. netPlayerController.super.handleActionBegin(self, actor, act)
  28. end
  29. -----------------------------------------------------------------------------
  30. function netPlayerController:handleActionCompleted(actor, actCompleted)
  31. netPlayerController.super.handleActionCompleted(self, actor, actCompleted)
  32. -- 足迹特效
  33. if actor:IsMoveEff() and SL:GetMetaValue("GAME_DATA", "disable_footprint_effect") ~= 1 then
  34. if actCompleted == global.MMO.ACTION_WALK or actCompleted == global.MMO.ACTION_RUN or actCompleted == global.MMO.ACTION_RIDE_RUN then
  35. local lastMapX = actor:GetLastMapX()
  36. local lastMapY = actor:GetLastMapY()
  37. local skipWalk = actor:GetMoveEffSkipWalk()
  38. local skipSwitch = actor:GetEffSkipWalkSwitch() or 0
  39. actor:SetMoveEffSkipWalk(not skipWalk and skipSwitch == 0)
  40. if lastMapX == 0xFFFF or lastMapY == 0xFFFF or (actCompleted == global.MMO.ACTION_WALK and skipWalk) then
  41. return
  42. end
  43. global.gameMapController:addEffectToMap(actor:GetMoveEff(), lastMapX, lastMapY)
  44. end
  45. end
  46. end
  47. function netPlayerController:handleActionProcess(actor, act, dt)
  48. end
  49. function netPlayerController:AddNetPlayerToWorld( param )
  50. local id = param.actorID
  51. local netPlayer = global.actorManager:CreateActor( id, global.MMO.ACTOR_PLAYER )
  52. if nil == netPlayer then
  53. return nil
  54. end
  55. -- bind handler
  56. netPlayer:SetGameActorActionHandler( self )
  57. netPlayer:SetSexID( param.sex )
  58. netPlayer:SetDirection( param.dir )
  59. netPlayer:SetAction( global.MMO.ACTION_IDLE )
  60. netPlayer:SetClothID( 0 )
  61. --
  62. local refreshData = {}
  63. refreshData.actor = netPlayer
  64. refreshData.actorID = param.actorID
  65. global.Facade:sendNotification(global.NoticeTable.DelayCreateHUDBar, refreshData)
  66. return netPlayer
  67. end
  68. function netPlayerController:handle_Die( actor, msgHdr )
  69. netPlayerController.super.handle_Die(self, actor, msgHdr)
  70. end
  71. function netPlayerController:Cleanup( cleanHandler )
  72. netPlayerController.super.Cleanup(self, cleanHandler)
  73. end
  74. return netPlayerController