BuffEntityFreezed.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. local BuffEntityAnim = require("buff/BuffEntityAnim")
  2. local BuffEntityFreezed = class("BuffEntityFreezed", BuffEntityAnim)
  3. function BuffEntityFreezed:ctor(data)
  4. BuffEntityFreezed.super.ctor(self, data)
  5. end
  6. function BuffEntityFreezed:OnEnter()
  7. BuffEntityFreezed.super.OnEnter(self)
  8. local actor = global.actorManager:GetActor(self._actorID)
  9. if not actor then
  10. self:disable()
  11. return false
  12. end
  13. if not (actor:IsPlayer() or actor:IsMonster()) then
  14. self:disable()
  15. return false
  16. end
  17. self:FreezeActor()
  18. end
  19. function BuffEntityFreezed:OnExit()
  20. BuffEntityFreezed.super.OnExit(self)
  21. local actor = global.actorManager:GetActor(self._actorID)
  22. if not actor then
  23. return nil
  24. end
  25. self:UnfreezeActor()
  26. end
  27. function BuffEntityFreezed:FreezeActor()
  28. local actor = global.actorManager:GetActor(self._actorID)
  29. if not actor then
  30. return nil
  31. end
  32. local function freeze(node)
  33. if self._buffID == global.MMO.BUFF_ID_FREEZED_GRAY then
  34. self:ShaderGray(node)
  35. end
  36. end
  37. if actor:IsPlayer() then
  38. local anim = actor:GetAnimation()
  39. if anim then
  40. freeze(anim)
  41. end
  42. anim = actor:GetAnimationWeapon()
  43. if anim then
  44. freeze(anim)
  45. end
  46. anim = actor:GetAnimationShield()
  47. if anim then
  48. freeze(anim)
  49. end
  50. anim = actor:GetAnimationWings()
  51. if anim then
  52. freeze(anim)
  53. end
  54. anim = actor:GetAnimationMount()
  55. if anim then
  56. freeze(anim)
  57. end
  58. anim = actor:GetAnimationHair()
  59. if anim then
  60. freeze(anim)
  61. end
  62. anim = actor:GetAnimationMonster()
  63. if anim then
  64. freeze(anim)
  65. end
  66. elseif actor:IsMonster() then
  67. local anim = actor:GetAnimation()
  68. if anim then
  69. freeze(anim)
  70. end
  71. end
  72. end
  73. function BuffEntityFreezed:UnfreezeActor()
  74. local actor = global.actorManager:GetActor(self._actorID)
  75. if not actor then
  76. return nil
  77. end
  78. local function unfreeze(node)
  79. self:ShaderNormal(node)
  80. end
  81. if actor:IsPlayer() then
  82. local anim = actor:GetAnimation()
  83. if anim then
  84. unfreeze(anim)
  85. end
  86. anim = actor:GetAnimationWeapon()
  87. if anim then
  88. unfreeze(anim)
  89. end
  90. anim = actor:GetAnimationShield()
  91. if anim then
  92. unfreeze(anim)
  93. end
  94. anim = actor:GetAnimationWings()
  95. if anim then
  96. unfreeze(anim)
  97. end
  98. anim = actor:GetAnimationMount()
  99. if anim then
  100. unfreeze(anim)
  101. end
  102. anim = actor:GetAnimationHair()
  103. if anim then
  104. unfreeze(anim)
  105. end
  106. anim = actor:GetAnimationMonster()
  107. if anim then
  108. unfreeze(anim)
  109. end
  110. elseif actor:IsMonster() then
  111. local anim = actor:GetAnimation()
  112. if anim then
  113. unfreeze(anim)
  114. end
  115. end
  116. end
  117. function BuffEntityFreezed:PauseActor()
  118. local actor = global.actorManager:GetActor(self._actorID)
  119. if not actor then
  120. return nil
  121. end
  122. local function pause(node)
  123. local AMgr = global.Director:getActionManager()
  124. AMgr:pauseTarget(node)
  125. end
  126. if actor:IsPlayer() then
  127. local anim = actor:GetAnimation()
  128. if anim then
  129. pause(anim)
  130. end
  131. anim = actor:GetAnimationWeapon()
  132. if anim then
  133. pause(anim)
  134. end
  135. anim = actor:GetAnimationShield()
  136. if anim then
  137. pause(anim)
  138. end
  139. anim = actor:GetAnimationWings()
  140. if anim then
  141. pause(anim)
  142. end
  143. anim = actor:GetAnimationMount()
  144. if anim then
  145. pause(anim)
  146. end
  147. anim = actor:GetAnimationHair()
  148. if anim then
  149. pause(anim)
  150. end
  151. anim = actor:GetAnimationMonster()
  152. if anim then
  153. pause(anim)
  154. end
  155. elseif actor:IsMonster() then
  156. local anim = actor:GetAnimation()
  157. if anim then
  158. pause(anim)
  159. end
  160. end
  161. end
  162. function BuffEntityFreezed:ResumeActor()
  163. local actor = global.actorManager:GetActor(self._actorID)
  164. if not actor then
  165. return nil
  166. end
  167. local function resume(node)
  168. local AMgr = global.Director:getActionManager()
  169. AMgr:resumeTarget(node)
  170. end
  171. if actor:IsPlayer() then
  172. local anim = actor:GetAnimation()
  173. if anim then
  174. resume(anim)
  175. end
  176. anim = actor:GetAnimationWeapon()
  177. if anim then
  178. resume(anim)
  179. end
  180. anim = actor:GetAnimationShield()
  181. if anim then
  182. resume(anim)
  183. end
  184. anim = actor:GetAnimationWings()
  185. if anim then
  186. resume(anim)
  187. end
  188. anim = actor:GetAnimationMount()
  189. if anim then
  190. resume(anim)
  191. end
  192. anim = actor:GetAnimationHair()
  193. if anim then
  194. resume(anim)
  195. end
  196. anim = actor:GetAnimationMonster()
  197. if anim then
  198. resume(anim)
  199. end
  200. elseif actor:IsMonster() then
  201. local anim = actor:GetAnimation()
  202. if anim then
  203. resume(anim)
  204. end
  205. end
  206. end
  207. function BuffEntityFreezed:ShaderGray(node)
  208. if not node then
  209. return
  210. end
  211. local p = global.GLProgramCache:getGLProgram("ShaderUIGrayScale")
  212. node:setGLProgram(p)
  213. end
  214. function BuffEntityFreezed:ShaderGold(node)
  215. if not node then
  216. return
  217. end
  218. global.Facade:sendNotification(global.NoticeTable.HighLightNodeShader, node, global.MMO.SHADER_TYPE_GOLDEN)
  219. end
  220. function BuffEntityFreezed:ShaderNormal(node)
  221. if not node then
  222. return
  223. end
  224. local p = global.GLProgramCache:getGLProgram("ShaderPositionTextureColor_noMVP")
  225. node:setGLProgram(p)
  226. end
  227. function BuffEntityFreezed:IsAllowAnimUpdate()
  228. return true
  229. end
  230. function BuffEntityFreezed:UpdatePresent()
  231. local actor = global.actorManager:GetActor(self._actorID)
  232. if not actor then
  233. return false
  234. end
  235. if not (actor:IsPlayer() or actor:IsMonster()) then
  236. return false
  237. end
  238. self:FreezeActor()
  239. end
  240. return BuffEntityFreezed