123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, director, find, Vec3, Cube_Infor, Cube_State, Container_Manager, _dec, _class, _crd, ccclass, property, CreateIdiom;
- function _reportPossibleCrUseOfCube_Infor(extras) {
- _reporterNs.report("Cube_Infor", "./Cube_Infor", _context.meta, extras);
- }
- function _reportPossibleCrUseOfCube_State(extras) {
- _reporterNs.report("Cube_State", "./Cube_Infor", _context.meta, extras);
- }
- function _reportPossibleCrUseOfContainer_Manager(extras) {
- _reporterNs.report("Container_Manager", "./Container_Manager", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Component = _cc.Component;
- director = _cc.director;
- find = _cc.find;
- Vec3 = _cc.Vec3;
- }, function (_unresolved_2) {
- Cube_Infor = _unresolved_2.Cube_Infor;
- Cube_State = _unresolved_2.Cube_State;
- }, function (_unresolved_3) {
- Container_Manager = _unresolved_3.Container_Manager;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "3b901oU5ZJHnp8TtJiYjZWZ", "CreateIdiom", undefined);
- __checkObsolete__(['_decorator', 'Component', 'debug', 'director', 'find', 'instantiate', 'Layers', 'Node', 'NodePool', 'Prefab', 'tween', 'Vec3']);
- ({
- ccclass,
- property
- } = _decorator);
- _export("CreateIdiom", CreateIdiom = (_dec = ccclass('CreateIdiom'), _dec(_class = class CreateIdiom extends Component {
- constructor(...args) {
- super(...args);
- this.count = 0;
- this.Container = void 0;
- }
- onLoad() {
- this.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
- error: Error()
- }), Container_Manager) : Container_Manager);
- }
- update(deltaTime) {}
- nodeMoving() {
- this.node.setPosition(new Vec3(0, 1.6, 0));
- let startPos = this.node.position; // 起点,抛物线开始的坐标
- let middlePos = new Vec3(this.node.position.x, this.node.position.y + 2, 0); // 中间控制点
- let destPos = new Vec3(this.node.position.x, this.node.position.y + 4, 0); // 终点,抛物线上升顶点
- // 保持原来贝塞尔曲线和螺旋效果的计算
- let twoBezier = (t, p1, cp, p2) => {
- // 贝塞尔曲线计算
- let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
- let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
- let z = (1 - t) * (1 - t) * p1.z + 2 * t * (1 - t) * cp.z + t * t * p2.z; // 螺旋运动计算
- let angle = t * Math.PI * 6; // 螺旋角度变化,增加圈数
- let radius = t * 3.5; // 螺旋半径逐渐增大
- let xOffset = Math.cos(angle) * radius; // x 轴偏移
- let zOffset = Math.sin(angle) * radius; // z 轴偏移
- // 返回最终点,带有螺旋效果
- return new Vec3(x + xOffset, y, z + zOffset);
- };
- let createdNodes = 0; // 已生成的节点计数
- let animationStopped = false; // 控制动画是否已经停止
- let t = 0; // 进度 t,0 为起点,1 为终点
- const updatePosition = () => {
- if (animationStopped) return; // 如果动画已停止,则不继续执行
- // 继续使用贝塞尔曲线计算,带螺旋效果
- this.node.position = twoBezier(t, startPos, middlePos, destPos); // 根据进度生成新节点
- let cube = this.Container.getCube();
- if (cube != null && cube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor).state === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
- error: Error()
- }), Cube_State) : Cube_State).live) {
- let newNode = cube;
- newNode.parent = director.getScene();
- newNode.setPosition(this.node.position);
- this.Container.nodeReferences.push(newNode);
- console.log(cube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor).Text);
- createdNodes++; // 记录生成的方块
- } // 如果没有方块,停止动画
- if (cube == null && !animationStopped) {
- animationStopped = true; // 设置动画停止标志
- console.log("没有方块,停止动画");
- this.node.setPosition(this.node.position); // 防止继续更新位置
- } // 获取 Container 中的当前方块数量
- let totalCubes = this.Container.idioms.length * 2; // 假设 idioms 存储了所有方块的信息
- // 如果所有方块都已生成,停止动画
- if (createdNodes >= totalCubes) {
- animationStopped = true;
- this.Container.canTouch = true;
- console.log("所有方块已拿完,停止动画");
- } // 更新 t 和重新调用动画
- if (t < 1) {
- t += 0.01; // 每次更新进度
- requestAnimationFrame(updatePosition); // 使用 requestAnimationFrame 来继续更新位置
- }
- }; // 启动动画
- updatePosition();
- }
- }) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=635d373e206601884c96847cb1eeeefae856f2ab.js.map
|