EffectUtils.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s,
  5. e =
  6. (this && this.__decorate) ||
  7. function (t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", {value: !0});
  18. const l = t("MoneyAni"),
  19. o = t("OpenSysAni"),
  20. h = (t("LayerManager"), t("BagController")),
  21. _ = t("App"),
  22. a = t("NodePool"),
  23. n = t("QueueExecutor");
  24. (t = {})[(t.Score = 0)] = "Score";
  25. const {ccclass: r, property: c} = cc._decorator;
  26. t = s = class extends cc.Component {
  27. constructor() {
  28. super(...arguments),
  29. (this.queueExecutor = null),
  30. (this.openSysAniPrefab = null),
  31. (this.openSysAni = null),
  32. (this.moneyAniPre = null),
  33. (this.moneyAniPool = null);
  34. }
  35. onLoad() {
  36. (this.queueExecutor = new n.QueueExecutor()),
  37. ((s.instance = this).moneyAniPool = new a.default()),
  38. (this.moneyAniPool.prefab = this.moneyAniPre);
  39. }
  40. playLockAni(e) {
  41. this.queueExecutor.regist(() => {
  42. let t = this.openSysAni;
  43. t || (this.openSysAni = t = cc.instantiate(this.openSysAniPrefab)),
  44. t.parent || (_.default.ViewManager.uiRoot.addChild(t), (t.zIndex = 100)),
  45. t.getComponent(o.default).play(e);
  46. }, this);
  47. }
  48. coinEffect1(i, s, o, a, n = 0, r, l = 7, h = 45) {
  49. let c = 0;
  50. var d = o / Math.abs(o),
  51. u = a / Math.abs(a);
  52. let p = !1;
  53. for (let e = 0; e < l; e++) {
  54. let t = this.pool.pop();
  55. 11 == Math.floor(n / 1e6)
  56. ? (t.getComponent(MoneyIcon).moneyType = n)
  57. : (t.getComponent(cc.Sprite).spriteFrame = this.frames[n]),
  58. (t.x = i),
  59. (t.y = s),
  60. (t.active = !1),
  61. (t.height = t.width = h);
  62. var f = Math.sqrt(Math.pow(i - o, 2) + Math.pow(s - a, 2));
  63. Math.sqrt(Math.pow(i - o, 2) + Math.pow(s - a, 2));
  64. var g = cc.v2(i + 200 * d, s - 300 * u);
  65. cc.v2((g.x + o) / 2, (g.y + a) / 2),
  66. cc
  67. .tween(t)
  68. .delay(c)
  69. .set({active: !0})
  70. .to(f / 1e3, {x: o, y: a}, {easing: cc.easing.quadOut})
  71. .delay(0.01)
  72. .call(() => {
  73. this.pool.push(t),
  74. e == l - 1 && this.queueExecutor.finishFunc(),
  75. p || ((p = !0), _.default.SoundManager.playEffect("get_coin2"));
  76. })
  77. .start(),
  78. (c += 0.1),
  79. r.addChild(t),
  80. (t.zIndex = 110);
  81. }
  82. }
  83. coinEffect2(i, s, o, a, n = 0, r, l = 7, h = 45) {
  84. let c = 0;
  85. var d = o / Math.abs(o),
  86. u = a / Math.abs(a);
  87. let p = !1;
  88. for (let e = 0; e < l; e++) {
  89. let t = this.pool.pop();
  90. 11 == Math.floor(n / 1e6)
  91. ? (t.getComponent(MoneyIcon).moneyType = n)
  92. : (t.getComponent(cc.Sprite).spriteFrame = this.frames[n]),
  93. (t.x = i),
  94. (t.y = s),
  95. (t.active = !1),
  96. (t.height = t.width = h);
  97. var f = Math.sqrt(Math.pow(i - o, 2) + Math.pow(s - a, 2)),
  98. g = cc.v2(i + 200 * d, s - 300 * u),
  99. m = cc.v2((g.x + o) / 2, (g.y + a) / 2);
  100. cc
  101. .tween(t)
  102. .delay(c)
  103. .set({active: !0})
  104. .bezierTo(f / 1200, g, m, cc.v2(o, a))
  105. .delay(0.01)
  106. .call(() => {
  107. this.pool.push(t),
  108. e == l - 1 && this.queueExecutor.finishFunc(),
  109. p || ((p = !0), _.default.SoundManager.playEffect("get_coin2"));
  110. })
  111. .start(),
  112. (c += 0.1),
  113. r.addChild(t),
  114. (t.zIndex = 110);
  115. }
  116. }
  117. coinEffect(e, i, s, o, a = 0, n, r = 20, l = 45, h = 800, c = 500) {
  118. let d = 0;
  119. (e -= l / 2), (i -= l / 2);
  120. let u = !1;
  121. for (let t = 0; t < r; t++) {
  122. let t = this.pool.pop();
  123. t.getComponent(cc.Sprite).spriteFrame = this.frames[a];
  124. var p = (0.5 - Math.random()) * h + e,
  125. f = (0.5 - Math.random()) * c + i;
  126. (t.x = e), (t.y = i), (t.active = !1), (t.height = t.width = l);
  127. var g = Math.sqrt(Math.pow(p - s, 2) + Math.pow(f - o, 2)),
  128. m = 1.3 * Math.sqrt(Math.pow(e - p, 2) + Math.pow(i - f, 2));
  129. cc
  130. .tween(t)
  131. .delay(d)
  132. .set({active: !0})
  133. .to(m / 1e3, {x: p, y: f}, {easing: cc.easing.quadOut})
  134. .to(g / 1e3, {x: s, y: o}, {easing: cc.easing.circIn})
  135. .delay(0.01)
  136. .call(() => {
  137. this.pool.push(t), u || ((u = !0), _.default.SoundManager.playEffect("get_coin2"));
  138. })
  139. .start(),
  140. (d += 0.01),
  141. n.addChild(t),
  142. (t.zIndex = 110);
  143. }
  144. }
  145. typerEffect(t, e = "", i = 200, s, o) {
  146. let a = 0,
  147. n = function () {
  148. t.string += e[a++];
  149. };
  150. var r = e.length;
  151. return (t.string = ""), _.default.TimerManager.doTimer(i, r, n, o, s, o), n;
  152. }
  153. scaleEffect(t, e = 0.94) {
  154. return cc
  155. .tween(t)
  156. .to(0.5, {scale: e}, cc.easeSineInOut())
  157. .to(0.5, {scale: 1}, cc.easeSineInOut())
  158. .union()
  159. .repeatForever()
  160. .start();
  161. }
  162. rotationEffect(t, e = 2) {
  163. return cc.tween(t).by(e, {angle: 360}).repeatForever().start();
  164. }
  165. rockObj(t, e = 0.08, i = 5, s = 0.7) {
  166. cc.tween(t)
  167. .repeatForever(
  168. cc
  169. .tween()
  170. .to(e, {angle: i})
  171. .to(2 * e, {angle: -i})
  172. .to(2 * e, {angle: i})
  173. .to(2 * e, {angle: -i})
  174. .to(e, {angle: 0})
  175. .delay(s)
  176. )
  177. .start();
  178. }
  179. flyObj(t, e, i = 50) {
  180. return cc.tween(t).by(e, {y: i}).by(e, {y: -i}).union().repeatForever().start();
  181. }
  182. playMoneyAni(t, e, i = 0, s, o, a) {
  183. let n = this.moneyAniPool.pop();
  184. const r = n.getComponent(l.MoneyAni);
  185. s.addChild(n), (n.zIndex = 110), (n.position = t);
  186. t = Math.sqrt(t.sub(e).magSqr()) / 900;
  187. 2e4 < i && (i %= h.CostType.coin),
  188. r.playAni(
  189. e,
  190. i,
  191. t,
  192. () => {
  193. a && a(), this.moneyAniPool.push(n);
  194. },
  195. o
  196. );
  197. }
  198. };
  199. e([c(cc.Prefab)], t.prototype, "openSysAniPrefab", void 0),
  200. e([c(cc.Prefab)], t.prototype, "moneyAniPre", void 0),
  201. (t = s = e([r], t)),
  202. (i.default = t = s);