gameActorStatePlayerCustom.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local gameActorState = require( "actor/gameActorState")
  2. local gameActorStatePlayerCustom = class('gameActorStatePlayerCustom', gameActorState)
  3. function gameActorStatePlayerCustom:ctor(actionID, animID)
  4. self._ACTION_ID = actionID
  5. self._ANIM_ID = animID
  6. gameActorStatePlayerCustom.super.ctor(self)
  7. end
  8. function gameActorStatePlayerCustom:GetStateID()
  9. return self._ACTION_ID
  10. end
  11. -----------------------------------------------------------------------------
  12. function gameActorStatePlayerCustom:Tick(dt, player)
  13. player.mCurrentActT = player.mCurrentActT - dt
  14. if 0 >= player.mCurrentActT and player.mIsConfirmed then
  15. if player.mActionHandler then
  16. player.mActionHandler:handleActionCompleted( player, self._ACTION_ID )
  17. end
  18. end
  19. -- confirmed timeout
  20. if player.mCurrentActT <= -5.0 then
  21. player:SetConfirmed(true)
  22. end
  23. end
  24. -----------------------------------------------------------------------------
  25. function gameActorStatePlayerCustom:OnEnter(player)
  26. if player.mActionHandler then
  27. player.mActionHandler:handleActionBegin( player, self._ACTION_ID, player.mOrient, 0 )
  28. end
  29. local clothID = player:GetAnimationID()
  30. local SkillPoxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  31. local sex = player:GetValueByKey( global.MMO.BUFF_PLAYER_AVATAR_SEX ) or player:GetSexID()
  32. local defaultTime = SkillPoxy:GetSkillActionTime(self._ACTION_ID, clothID, sex) or global.MMO.DEFAULT_BTXD_TIME
  33. local actionSpeed = player:GetAttackSpeed()
  34. if SkillPoxy:GetSkillActionSpeed(self._ANIM_ID) == 1 then
  35. actionSpeed = player:GetMagicSpeed()
  36. end
  37. local animTime = defaultTime / actionSpeed
  38. player.mAnimTime = animTime
  39. player.mCurrentActT = animTime
  40. player:SetConfirmed(true)
  41. -- reset some data
  42. player:SetAnimPrepare( 0.0 )
  43. player:dirtyAnimFlag()
  44. end
  45. -----------------------------------------------------------------------------
  46. function gameActorStatePlayerCustom:OnExit(player)
  47. -- reset prepare time
  48. player:SetAnimPrepare(3)
  49. --
  50. player:SetAnimAct(global.MMO.ANIM_READY)
  51. player:dirtyAnimFlag()
  52. end
  53. -----------------------------------------------------------------------------
  54. function gameActorStatePlayerCustom:ChangeState(newState, player, isTerminate)
  55. player.mCurrentState = newState
  56. return true
  57. end
  58. return gameActorStatePlayerCustom
  59. -----------------------------------------------------------------------------