BuffEntityStoneMode.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. --[[
  2. author:yzy
  3. time:2022-04-20 11:16:04
  4. desc: 怪物石头状态, 就是置灰 设置SetStoneMode 停在动画第一帧
  5. ]]
  6. local BuffEntityAnim = require("buff/BuffEntityAnim")
  7. local BuffEntityStoneMode = class("BuffEntityStoneMode", BuffEntityAnim)
  8. function BuffEntityStoneMode:ctor(data)
  9. BuffEntityStoneMode.super.ctor(self, data)
  10. self._autoRemove = false --强制不自动移除
  11. end
  12. function BuffEntityStoneMode:OnEnter()
  13. BuffEntityStoneMode.super.OnEnter(self)
  14. local actor = global.actorManager:GetActor(self._actorID)
  15. if not actor then
  16. self:disable()
  17. return false
  18. end
  19. if actor:IsMonster() then
  20. actor:SetStoneMode(true)
  21. actor:stopAnimToFrame(1)
  22. else
  23. self:disable()
  24. return false
  25. end
  26. self:StoneActor()
  27. end
  28. function BuffEntityStoneMode:OnExit()
  29. BuffEntityStoneMode.super.OnExit(self)
  30. local actor = global.actorManager:GetActor(self._actorID)
  31. if not actor then
  32. return nil
  33. end
  34. if actor:IsMonster() then
  35. actor:SetStoneMode(false)
  36. actor:stopAnimToFrame(nil)
  37. end
  38. self:UnStoneActor()
  39. end
  40. function BuffEntityStoneMode:StoneActor()
  41. local actor = global.actorManager:GetActor(self._actorID)
  42. if not actor then
  43. return nil
  44. end
  45. self.isDelayDirty = nil
  46. local function shaderNode(node)
  47. self:ShaderStone(node)
  48. end
  49. if actor:IsPlayer() then
  50. local anim = actor:GetAnimation()
  51. if anim then
  52. shaderNode(anim)
  53. end
  54. anim = actor:GetAnimationWeapon()
  55. if anim then
  56. shaderNode(anim)
  57. end
  58. anim = actor:GetAnimationShield()
  59. if anim then
  60. shaderNode(anim)
  61. end
  62. anim = actor:GetAnimationMount()
  63. if anim then
  64. shaderNode(anim)
  65. end
  66. anim = actor:GetAnimationHair()
  67. if anim then
  68. shaderNode(anim)
  69. end
  70. elseif actor:IsMonster() then
  71. local anim = actor:GetAnimation()
  72. if anim then
  73. shaderNode(anim)
  74. end
  75. elseif actor:IsNPC() then
  76. local anim = actor:GetAnimation()
  77. if anim then
  78. shaderNode(anim)
  79. end
  80. end
  81. end
  82. function BuffEntityStoneMode:UnStoneActor()
  83. local actor = global.actorManager:GetActor(self._actorID)
  84. if not actor then
  85. return nil
  86. end
  87. local function shaderNode(node)
  88. self:ShaderNormal(node)
  89. end
  90. if actor:IsPlayer() then
  91. local anim = actor:GetAnimation()
  92. if anim then
  93. shaderNode(anim)
  94. end
  95. anim = actor:GetAnimationWeapon()
  96. if anim then
  97. shaderNode(anim)
  98. end
  99. anim = actor:GetAnimationShield()
  100. if anim then
  101. shaderNode(anim)
  102. end
  103. anim = actor:GetAnimationMount()
  104. if anim then
  105. shaderNode(anim)
  106. end
  107. anim = actor:GetAnimationHair()
  108. if anim then
  109. shaderNode(anim)
  110. end
  111. elseif actor:IsMonster() then
  112. local anim = actor:GetAnimation()
  113. if anim then
  114. shaderNode(anim)
  115. end
  116. elseif actor:IsNPC() then
  117. local anim = actor:GetAnimation()
  118. if anim then
  119. shaderNode(anim)
  120. end
  121. end
  122. end
  123. function BuffEntityStoneMode:ShaderStone(node)
  124. if not node then
  125. return
  126. end
  127. local p = global.GLProgramCache:getGLProgram("ShaderUIGrayScale")
  128. node:setGLProgram(p)
  129. end
  130. function BuffEntityStoneMode:ShaderNormal(node)
  131. if not node then
  132. return
  133. end
  134. local p = global.GLProgramCache:getGLProgram("ShaderPositionTextureColor_noMVP")
  135. node:setGLProgram(p)
  136. end
  137. function BuffEntityStoneMode:UpdatePresent()
  138. self:StoneActor()
  139. end
  140. return BuffEntityStoneMode