0e6be8836ae46289898f43dcc0bb4e16f4e5502e.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, director, find, tween, Vec3, Cube_Infor, Cube_State, Container_Manager, _dec, _class, _crd, ccclass, property, CreateIdiom;
  4. function _reportPossibleCrUseOfCube_Infor(extras) {
  5. _reporterNs.report("Cube_Infor", "./Cube_Infor", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfCube_State(extras) {
  8. _reporterNs.report("Cube_State", "./Cube_Infor", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfContainer_Manager(extras) {
  11. _reporterNs.report("Container_Manager", "./Container_Manager", _context.meta, extras);
  12. }
  13. return {
  14. setters: [function (_unresolved_) {
  15. _reporterNs = _unresolved_;
  16. }, function (_cc) {
  17. _cclegacy = _cc.cclegacy;
  18. __checkObsolete__ = _cc.__checkObsolete__;
  19. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  20. _decorator = _cc._decorator;
  21. Component = _cc.Component;
  22. director = _cc.director;
  23. find = _cc.find;
  24. tween = _cc.tween;
  25. Vec3 = _cc.Vec3;
  26. }, function (_unresolved_2) {
  27. Cube_Infor = _unresolved_2.Cube_Infor;
  28. Cube_State = _unresolved_2.Cube_State;
  29. }, function (_unresolved_3) {
  30. Container_Manager = _unresolved_3.Container_Manager;
  31. }],
  32. execute: function () {
  33. _crd = true;
  34. _cclegacy._RF.push({}, "3b901oU5ZJHnp8TtJiYjZWZ", "CreateIdiom", undefined);
  35. __checkObsolete__(['_decorator', 'Component', 'debug', 'director', 'find', 'instantiate', 'Layers', 'Node', 'NodePool', 'Prefab', 'tween', 'Vec3']);
  36. ({
  37. ccclass,
  38. property
  39. } = _decorator);
  40. _export("CreateIdiom", CreateIdiom = (_dec = ccclass('CreateIdiom'), _dec(_class = class CreateIdiom extends Component {
  41. constructor(...args) {
  42. super(...args);
  43. this.count = 0;
  44. this.Container = void 0;
  45. }
  46. onLoad() {
  47. this.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  48. error: Error()
  49. }), Container_Manager) : Container_Manager);
  50. }
  51. update(deltaTime) {}
  52. nodeMoving() {
  53. this.node.setPosition(new Vec3(0, 0.3, 0));
  54. let startPos = this.node.position; // 起点,抛物线开始的坐标
  55. let middlePos = new Vec3(this.node.position.x, this.node.position.y, 0); // 中间控制点
  56. let destPos = new Vec3(this.node.position.x, this.node.position.y, 0); // 终点,抛物线上升顶点
  57. let twoBezier = (t, p1, cp, p2) => {
  58. // 贝塞尔曲线计算
  59. let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
  60. let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y; // 螺旋运动计算
  61. let angle = t * Math.PI * 6; // 螺旋角度变化,增加圈数
  62. let radius = 0.5 + t * 2.5; // 螺旋半径逐渐增大
  63. let xOffset = Math.cos(angle) * radius; // x 轴偏移
  64. let zOffset = Math.sin(angle) * radius; // z 轴偏移
  65. // 返回最终点,带有螺旋效果
  66. return new Vec3(x + xOffset, y, zOffset);
  67. };
  68. let tweenDuration = 1.0; // 动画时长
  69. let createdNodes = 0; // 已生成的节点计数
  70. tween(this.node.position).to(tweenDuration, destPos, {
  71. onUpdate: (target, ratio) => {
  72. // 计算新的位置,带螺旋上升效果
  73. this.node.position = twoBezier(ratio, startPos, middlePos, destPos); // 根据进度生成新节点
  74. let cube = this.Container.getCube();
  75. if (cube != null && cube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  76. error: Error()
  77. }), Cube_Infor) : Cube_Infor).state === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  78. error: Error()
  79. }), Cube_State) : Cube_State).live) {
  80. let newNode = cube;
  81. newNode.parent = director.getScene();
  82. newNode.setPosition(this.node.position);
  83. this.Container.nodeReferences.push(newNode);
  84. console.log(cube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  85. error: Error()
  86. }), Cube_Infor) : Cube_Infor).Text);
  87. }
  88. }
  89. }).start();
  90. }
  91. }) || _class));
  92. _cclegacy._RF.pop();
  93. _crd = false;
  94. }
  95. };
  96. });
  97. //# sourceMappingURL=0e6be8836ae46289898f43dcc0bb4e16f4e5502e.js.map