cb13e961bcd8d7069545036fc45d02908c0eee94.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Component, Node, UIOpacity, UITransform, Vec3, Widget, _decorator, easing, instantiate, tween, v3, _dec, _dec2, _class, _crd, ccclass, requireComponent, RewardFly;
  4. return {
  5. setters: [function (_cc) {
  6. _cclegacy = _cc.cclegacy;
  7. __checkObsolete__ = _cc.__checkObsolete__;
  8. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  9. Component = _cc.Component;
  10. Node = _cc.Node;
  11. UIOpacity = _cc.UIOpacity;
  12. UITransform = _cc.UITransform;
  13. Vec3 = _cc.Vec3;
  14. Widget = _cc.Widget;
  15. _decorator = _cc._decorator;
  16. easing = _cc.easing;
  17. instantiate = _cc.instantiate;
  18. tween = _cc.tween;
  19. v3 = _cc.v3;
  20. }],
  21. execute: function () {
  22. _crd = true;
  23. _cclegacy._RF.push({}, "9d999oa7ZtO/Jhnk1+iN63E", "RewardFly", undefined);
  24. __checkObsolete__(['Component', 'EventTouch', 'Node', 'Prefab', 'UIOpacity', 'UITransform', 'Vec3', 'Widget', '_decorator', 'easing', 'instantiate', 'tween', 'v3']);
  25. ({
  26. ccclass,
  27. requireComponent
  28. } = _decorator);
  29. _export("RewardFly", RewardFly = (_dec = ccclass('RewardFly'), _dec2 = requireComponent(UITransform), _dec(_class = _dec2(_class = class RewardFly extends Component {
  30. onLoad() {//this.node.on(Node.EventType.TOUCH_START, function (event: EventTouch) {
  31. //event.propagationStopped = true;
  32. //event.preventSwallow = true;
  33. //}, this, true);
  34. }
  35. onDisable() {
  36. this.node.destroyAllChildren();
  37. }
  38. convertToNodeSpaceAR(target) {
  39. if (target instanceof Node) {
  40. return this.node.getComponent(UITransform).convertToNodeSpaceAR(target.getComponent(UITransform).convertToWorldSpaceAR(Vec3.ZERO));
  41. }
  42. return this.node.getComponent(UITransform).convertToNodeSpaceAR(target);
  43. }
  44. add(opts) {
  45. const startPos = this.convertToNodeSpaceAR(opts.start);
  46. const endPos = this.convertToNodeSpaceAR(opts.end);
  47. if (opts.endOffset) {
  48. endPos.add3f(opts.endOffset[0], opts.endOffset[1], 0);
  49. }
  50. let nodeCopy = null;
  51. if (opts.highlight) {
  52. if (opts.highlightOffset) {
  53. endPos.add3f(opts.highlightOffset[0], opts.highlightOffset[1], 0);
  54. }
  55. if (opts.highlightArea) {
  56. var _nodeCopy$getComponen;
  57. const endAreaPos = this.convertToNodeSpaceAR(opts.highlightArea);
  58. if (opts.highlightOffset) {
  59. endAreaPos.add3f(opts.highlightOffset[0], opts.highlightOffset[1], 0);
  60. }
  61. nodeCopy = instantiate(opts.highlightArea);
  62. (_nodeCopy$getComponen = nodeCopy.getComponent(Widget)) == null || _nodeCopy$getComponen.destroy();
  63. nodeCopy.setParent(this.node);
  64. nodeCopy.setPosition(endAreaPos);
  65. } else if (Node.isNode(opts.end)) {
  66. var _nodeCopy$getComponen2;
  67. nodeCopy = instantiate(opts.end);
  68. (_nodeCopy$getComponen2 = nodeCopy.getComponent(Widget)) == null || _nodeCopy$getComponen2.destroy();
  69. nodeCopy.setParent(this.node);
  70. nodeCopy.setPosition(endPos);
  71. }
  72. }
  73. for (let index = 0; index < opts.count; index++) {
  74. const aniNode = instantiate(opts.item);
  75. aniNode.setPosition(startPos);
  76. aniNode.setParent(this.node); // 炸开位置
  77. const midPos = v3(startPos.x, startPos.y, 0);
  78. midPos.x += (Math.random() * 2 - 1) * (opts.startRange ? opts.startRange[0] : 100);
  79. midPos.y += (Math.random() * 2 - 1) * (opts.startRange ? opts.startRange[1] : 100); // 执行动画
  80. (aniNode.getComponent(UIOpacity) || aniNode.addComponent(UIOpacity)).opacity = 0;
  81. tween(aniNode).delay(index * 0.025).call(() => {
  82. aniNode.getComponent(UIOpacity).opacity = 200;
  83. tween(aniNode.getComponent(UIOpacity)).to(0.4, {
  84. opacity: 255
  85. }, {
  86. easing: easing.expoOut
  87. }).start();
  88. }).to(0.4, {
  89. position: midPos
  90. }, {
  91. easing: easing.expoOut
  92. }).call(() => {
  93. tween(aniNode.getComponent(UIOpacity)).delay(0.5).to(0.1, {
  94. opacity: 70
  95. }).start();
  96. }).to(0.6, {
  97. position: endPos
  98. }, {
  99. easing: easing.expoIn
  100. }).call(() => {
  101. if (index === 0) {
  102. // 结束节点缩放
  103. if (nodeCopy) {
  104. const scale = v3(nodeCopy.scale);
  105. tween(nodeCopy).to(0.1, {
  106. scale: v3(scale.x * 1.3, scale.y * 1.3)
  107. }).delay(0.025 * Math.max(opts.count, 4)).to(0.1, {
  108. scale: scale
  109. }).call(() => {
  110. // 结束节点透明销毁
  111. const uiOpacity = nodeCopy.getComponent(UIOpacity) || nodeCopy.addComponent(UIOpacity);
  112. tween(uiOpacity).to(0.1, {
  113. opacity: uiOpacity.opacity * 0.3
  114. }).call(() => nodeCopy.destroy()).start();
  115. }).start();
  116. }
  117. opts.onBegin && opts.onBegin(nodeCopy);
  118. }
  119. opts.onContact && opts.onContact(nodeCopy);
  120. }).delay(0.01).call(() => {
  121. aniNode.destroy();
  122. if (index === opts.count - 1) {
  123. opts.onFinish && opts.onFinish(nodeCopy);
  124. }
  125. }).start();
  126. }
  127. }
  128. }) || _class) || _class));
  129. _cclegacy._RF.pop();
  130. _crd = false;
  131. }
  132. };
  133. });
  134. //# sourceMappingURL=cb13e961bcd8d7069545036fc45d02908c0eee94.js.map