123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7", "__unresolved_8", "__unresolved_9", "__unresolved_10", "__unresolved_11"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Camera, Component, find, geometry, Layers, Node, PhysicsSystem, Quat, RigidBody, sp, tween, Vec3, gui, UI_Idioms, UI_Main, Container_Manager, Cube_Infor, Cube_State, UI_LatticeFull, UI_Lock, Toast, ch_audio, Hall, ch, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _class3, _crd, ccclass, property, GameCtl;
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
- function _reportPossibleCrUseOfgui(extras) {
- _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
- }
- function _reportPossibleCrUseOfUI_Idioms(extras) {
- _reporterNs.report("UI_Idioms", "../ui/UI_Idioms/UI_Idioms", _context.meta, extras);
- }
- function _reportPossibleCrUseOfUI_Main(extras) {
- _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras);
- }
- function _reportPossibleCrUseOfContainer_Manager(extras) {
- _reporterNs.report("Container_Manager", "./Container_Manager", _context.meta, extras);
- }
- 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 _reportPossibleCrUseOfUI_LatticeFull(extras) {
- _reporterNs.report("UI_LatticeFull", "../ui/UI_LatticeFull/UI_LatticeFull", _context.meta, extras);
- }
- function _reportPossibleCrUseOfUI_Lock(extras) {
- _reporterNs.report("UI_Lock", "../ui/UI_Lock/UI_Lock", _context.meta, extras);
- }
- function _reportPossibleCrUseOfLayout_Main(extras) {
- _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras);
- }
- function _reportPossibleCrUseOfToast(extras) {
- _reporterNs.report("Toast", "../../core/util_class/Toast", _context.meta, extras);
- }
- function _reportPossibleCrUseOfch_audio(extras) {
- _reporterNs.report("ch_audio", "../../ch/audio/audio", _context.meta, extras);
- }
- function _reportPossibleCrUseOfHall(extras) {
- _reporterNs.report("Hall", "../hall/Hall", _context.meta, extras);
- }
- function _reportPossibleCrUseOfch(extras) {
- _reporterNs.report("ch", "../../ch/ch", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Camera = _cc.Camera;
- Component = _cc.Component;
- find = _cc.find;
- geometry = _cc.geometry;
- Layers = _cc.Layers;
- Node = _cc.Node;
- PhysicsSystem = _cc.PhysicsSystem;
- Quat = _cc.Quat;
- RigidBody = _cc.RigidBody;
- sp = _cc.sp;
- tween = _cc.tween;
- Vec3 = _cc.Vec3;
- }, function (_unresolved_2) {
- gui = _unresolved_2.gui;
- }, function (_unresolved_3) {
- UI_Idioms = _unresolved_3.UI_Idioms;
- }, function (_unresolved_4) {
- UI_Main = _unresolved_4.UI_Main;
- }, function (_unresolved_5) {
- Container_Manager = _unresolved_5.Container_Manager;
- }, function (_unresolved_6) {
- Cube_Infor = _unresolved_6.Cube_Infor;
- Cube_State = _unresolved_6.Cube_State;
- }, function (_unresolved_7) {
- UI_LatticeFull = _unresolved_7.UI_LatticeFull;
- }, function (_unresolved_8) {
- UI_Lock = _unresolved_8.UI_Lock;
- }, function (_unresolved_9) {
- Toast = _unresolved_9.Toast;
- }, function (_unresolved_10) {
- ch_audio = _unresolved_10.default;
- }, function (_unresolved_11) {
- Hall = _unresolved_11.Hall;
- }, function (_unresolved_12) {
- ch = _unresolved_12.ch;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "5237f+4/ftIlKW+rC062l8C", "GameCtl", undefined);
- __checkObsolete__(['_decorator', 'BoxCollider', 'Camera', 'Component', 'director', 'EventTouch', 'find', 'Game', 'geometry', 'Layers', 'Layout', 'Node', 'PhysicsSystem', 'Quat', 'RigidBody', 'Size', 'sp', 'tween', 'UITransform', 'v3', 'Vec3']);
- ({
- ccclass,
- property
- } = _decorator);
- _export("GameCtl", GameCtl = (_dec = ccclass('GameCtl'), _dec2 = property(Camera), _dec3 = property([Node]), _dec4 = property(Node), _dec(_class = (_class2 = (_class3 = class GameCtl extends Component {
- constructor(...args) {
- super(...args);
- _initializerDefineProperty(this, "camera", _descriptor, this);
- _initializerDefineProperty(this, "Ani", _descriptor2, this);
- _initializerDefineProperty(this, "Mid", _descriptor3, this);
- this.Container = void 0;
- }
- onLoad() {
- GameCtl.instance = this;
- this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
- this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
- this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- this.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
- error: Error()
- }), Container_Manager) : Container_Manager);
- }
- update(deltaTime) {}
- onTouchStart(event) {}
- onTouchMove(event) {}
- onTouchEnd(event) {
- if (this.Container.canTouch) {
- this.shootRay(event);
- }
- }
- shootRay(event) {
- if (!this.camera) return;
- let ray = new geometry.Ray();
- this.camera.screenPointToRay(event.getLocationX(), event.getLocationY(), ray);
- if (PhysicsSystem.instance.raycast(ray)) {
- const results = PhysicsSystem.instance.raycastResults; // 筛选出不在 "IGNORE_RAYCAST" 层的物体
- let filteredResults = results.filter(e => e.collider.node.layer !== 1 << Layers.nameToLayer('IGNORE_RAYCAST')); // 根据距离排序,确保第 0 个是最近的物体
- filteredResults.sort((a, b) => a.distance - b.distance);
- console.log(filteredResults);
- if (filteredResults.length > 0) {
- var _node$getComponent;
- const collider = filteredResults[0].collider;
- const node = collider.node; // 检查物体是否可消除
- if (((_node$getComponent = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor)) == null ? void 0 : _node$getComponent.state) === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
- error: Error()
- }), Cube_State) : Cube_State).live) {
- (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
- error: Error()
- }), ch_audio) : ch_audio).getInstance().playOneShot('sound/click_Cube');
- if ((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
- error: Error()
- }), Hall) : Hall).getInstance().firstEnter) {
- if (this.Container.nodeReferences.length > 4) {
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
- error: Error()
- }), UI_Main) : UI_Main).getLayout().Hands[this.Container.nodeReferences.indexOf(node)].active = false;
- }
- }
- this.entryContainer(node);
- } else if (node.name === 'Lock') {
- this.UnLock(node);
- }
- }
- }
- console.log('发射了射线');
- }
- entryContainer(node) {
- // 判断容器剩余容量
- let startIndex = -1;
- let targetPos = new Vec3();
- let txt_length = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor).Text.length;
- console.log(txt_length); // 判断字长 并 判断是否还有空间可放置
- switch (txt_length) {
- case 1:
- for (let i = 0; i < this.Container.unlock_Num; i++) {
- if (this.Container.node_isIdiom[i] === false) {
- startIndex = i; // 找到连续的三个 false,记录起始位置
- break; // 找到第一个符合条件的位置后停止
- }
- }
- if (startIndex !== -1) {
- // 如果找到了一个值为 false 的元素
- targetPos = this.Container.nodes[startIndex].getWorldPosition().clone();
- this.Container.node_isIdiom[startIndex] = true;
- console.log(targetPos);
- } else {
- (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
- error: Error()
- }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
- }
- break;
- case 2:
- {
- for (let i = 0; i < this.Container.unlock_Num - 1; i++) {
- if (this.Container.node_isIdiom[i] === false && this.Container.node_isIdiom[i + 1] === false) {
- startIndex = i; // 找到连续的两个 false,记录起始位置
- break; // 找到第一个符合条件的位置后停止
- }
- }
- if (startIndex !== -1) {
- console.log("找到连续的两个 false,起始索引是:", startIndex); // 可以在此使用 startIndex 进行后续操作,例如:
- let pos1 = this.Container.nodes[startIndex].getWorldPosition();
- let pos2 = this.Container.nodes[startIndex + 1].getWorldPosition();
- this.Container.node_isIdiom[startIndex] = true;
- this.Container.node_isIdiom[startIndex + 1] = true;
- targetPos.set((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2, (pos1.z + pos2.z) / 2);
- console.log(targetPos);
- } else {
- (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
- error: Error()
- }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
- }
- break;
- }
- case 3:
- {
- for (let i = 0; i < this.Container.unlock_Num - 2; i++) {
- if (this.Container.node_isIdiom[i] === false && this.Container.node_isIdiom[i + 1] === false && this.Container.node_isIdiom[i + 2] === false) {
- startIndex = i; // 找到连续的三个 false,记录起始位置
- break; // 找到第一个符合条件的位置后停止
- }
- }
- if (startIndex !== -1) {
- // 找到连续三个 false,startIndex 即为最前面的索引
- console.log("找到连续的三个 false,起始索引是:", startIndex); // 可以在此使用 startIndex 进行后续操作,例如:
- let pos1 = this.Container.nodes[startIndex].getWorldPosition();
- let pos2 = this.Container.nodes[startIndex + 1].getWorldPosition();
- let pos3 = this.Container.nodes[startIndex + 2].getWorldPosition();
- this.Container.node_isIdiom[startIndex] = true;
- this.Container.node_isIdiom[startIndex + 1] = true;
- this.Container.node_isIdiom[startIndex + 2] = true;
- targetPos.set((pos1.x + pos2.x + pos3.x) / 3, (pos1.y + pos2.y + pos3.y) / 3, (pos1.z + pos2.z + pos3.z) / 3);
- console.log(targetPos);
- } else {
- (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
- error: Error()
- }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
- }
- break;
- }
- default:
- return;
- }
- if (startIndex !== -1) {
- // node.getComponent(Cube_Infor).lock = true;
- //生成一个新方块在场上剩余方块的方块的下方
- this.Container.instantiateNewCube();
- node.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).wait;
- node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; // 禁用重力
- let targetRotation = new Quat();
- let rotationX = node.eulerAngles.x; // 由于你初始是绕 X 轴旋转了 -90度,所以判断区间可以参考这个旋转角度
- if (rotationX >= -180 && rotationX < 0) {
- Quat.fromEuler(targetRotation, -90, 0, 0);
- } else {
- Quat.fromEuler(targetRotation, 90, 0, 0);
- }
- this.Container.canTouch = false;
- tween(node).to(0.02, {
- position: new Vec3(node.position.x, 5, node.position.z),
- rotation: targetRotation
- }).to(0.2, {
- position: new Vec3(targetPos.x, targetPos.y, targetPos.z + 0.4),
- rotation: targetRotation
- }).call(() => {
- this.Container.idiom_combine.set(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor), startIndex); // 执行判断成语合成逻辑
- let matchedCubes = [];
- let flag = this.Container.checkIdiom_Combine(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor), matchedCubes);
- if (flag) {
- // 执行合成动画
- console.log("匹配的成语方块:", matchedCubes);
- this.combine_ani(matchedCubes[0], matchedCubes[1]);
- } else {
- //高亮
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
- error: Error()
- }), UI_Idioms) : UI_Idioms).light_Show(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
- error: Error()
- }), Cube_Infor) : Cube_Infor)); //判断槽子满了吗
- let count = 0;
- for (let element of this.Container.node_isIdiom) {
- if (element == true) {
- count++;
- }
- }
- if (count == this.Container.unlock_Num) {
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).show(_crd && UI_LatticeFull === void 0 ? (_reportPossibleCrUseOfUI_LatticeFull({
- error: Error()
- }), UI_LatticeFull) : UI_LatticeFull);
- } else if (count >= this.Container.unlock_Num - 2 && this.Container.unlock_Num != 9) {
- if (!this.Container.is_Show_UI_Lock) {
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).show(_crd && UI_Lock === void 0 ? (_reportPossibleCrUseOfUI_Lock({
- error: Error()
- }), UI_Lock) : UI_Lock);
- this.Container.is_Show_UI_Lock = true;
- }
- }
- this.Container.canTouch = true;
- }
- }).start();
- }
- } //合成动画
- combine_ani(cube1, cube2) {
- this.Container.canTouch = true;
- for (let i = this.Container.idiom_combine.get(cube1); i < this.Container.idiom_combine.get(cube1) + cube1.Text.length; i++) {
- this.Container.node_isIdiom[i] = false;
- }
- this.Container.idiom_combine.delete(cube1);
- for (let i = this.Container.idiom_combine.get(cube2); i < this.Container.idiom_combine.get(cube2) + cube2.Text.length; i++) {
- this.Container.node_isIdiom[i] = false;
- }
- this.Container.idiom_combine.delete(cube2); // 取消相关字的高亮显示
- console.log(this.Container.node_isIdiom);
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
- error: Error()
- }), UI_Idioms) : UI_Idioms).light_Hide(cube1, cube2);
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
- error: Error()
- }), UI_Main) : UI_Main).evt.emit((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
- error: Error()
- }), UI_Main) : UI_Main).evt.key.update_remain);
- this.adjustContainer();
- let index1 = 0;
- if (cube1.Text.length == 1) {
- index1 = 0;
- } else if (cube1.Text.length == 2) {
- index1 = 2;
- } else if (cube1.Text.length == 3) {
- index1 = 4;
- }
- let index2 = 0;
- if (cube2.Text.length == 1) {
- index2 = 5;
- } else if (cube2.Text.length == 2) {
- index2 = 3;
- } else if (cube2.Text.length == 3) {
- index2 = 1;
- } // 检测容器中哪些字需要高亮显示
- console.log(this.Container.node_isIdiom); // 在所有动画结束后执行
- const str = this.Container.idioms.filter(c => c.idiom !== cube1.Text + cube2.Text);
- this.Container.idioms = str; // 创建第一个 tween 动画
- (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
- error: Error()
- }), ch_audio) : ch_audio).getInstance().playOneShot('sound/fly_Cube');
- const tween1 = tween(cube1.node).to(0.25, {
- position: new Vec3(this.Mid[0].position.x, this.Mid[0].position.y, this.Mid[0].position.z)
- }).call(() => {
- cube1.node.layer = 1 << Layers.nameToLayer('Cube2');
- cube1.node.walk(child => {
- child.layer = 1 << Layers.nameToLayer('Cube2');
- });
- this.playAnim();
- (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
- error: Error()
- }), ch_audio) : ch_audio).getInstance().playOneShot('sound/eliminate'); // this.Container.skeleton2.getComponent(sp.Skeleton).setAnimation(0, 'anim2', false);
- }).to(0.3, {
- position: new Vec3(this.Ani[index1].position.x, this.Ani[index1].position.y, this.Ani[index1].position.z + 0.4)
- }).call(() => {
- setTimeout(() => {
- cube1.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
- error: Error()
- }), Cube_State) : Cube_State).dead;
- this.Container.recycleCube(cube1.node);
- }, 600.0);
- }); // 创建第二个 tween 动画
- const tween2 = tween(cube2.node).to(0.3, {
- position: new Vec3(this.Mid[1].position.x, this.Mid[1].position.y, this.Mid[1].position.z)
- }).call(() => {
- cube2.node.layer = 1 << Layers.nameToLayer('Cube2');
- cube2.node.walk(child => {
- child.layer = 1 << Layers.nameToLayer('Cube2');
- });
- }).to(0.25, {
- position: new Vec3(this.Ani[index2].position.x, this.Ani[index2].position.y, this.Ani[index2].position.z + 0.4)
- }).call(() => {
- setTimeout(() => {
- cube2.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
- error: Error()
- }), Cube_State) : Cube_State).dead;
- this.Container.recycleCube(cube2.node);
- }, 600.0);
- }); // 使用 tween 的并行组合功能
- tween(cube1.node).parallel(tween1, tween2) // 并行执行 tween1 和 tween2
- .call(() => {
- (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
- error: Error()
- }), Hall) : Hall).getInstance().player.set_combine_num(1);
- if ((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
- error: Error()
- }), Hall) : Hall).getInstance().firstEnter) {
- if (this.Container.nodeReferences.length == 4) {
- this.Container.nodeReferences.forEach(node => {
- node.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;
- });
- }
- }
- }).start();
- }
- adjustContainer() {
- const container = this.Container; // 新的 node_isIdiom 状态数组
- const newNodeIsIdiom = Array(container.node_isIdiom.length).fill(false); // 新的 idiom_combine 映射表
- const newIdiomCombine = new Map(); // 遍历 idiom_combine,重新计算位置
- for (const [cube, startIndex] of container.idiom_combine.entries()) {
- const txtLength = cube.Text.length; // 获取字长
- let targetIndex = -1; // 目标位置起始索引
- let targetPos = new Vec3();
- switch (txtLength) {
- case 1:
- {
- // 找到一个空位
- for (let i = 0; i < container.unlock_Num; i++) {
- if (!newNodeIsIdiom[i]) {
- targetIndex = i;
- break;
- }
- }
- if (targetIndex !== -1) {
- targetPos = container.nodes[targetIndex].getWorldPosition().clone();
- newNodeIsIdiom[targetIndex] = true; // 占用位置
- }
- break;
- }
- case 2:
- {
- // 找到连续两个空位
- for (let i = 0; i < container.unlock_Num - 1; i++) {
- if (!newNodeIsIdiom[i] && !newNodeIsIdiom[i + 1]) {
- targetIndex = i;
- break;
- }
- }
- if (targetIndex !== -1) {
- const pos1 = container.nodes[targetIndex].getWorldPosition();
- const pos2 = container.nodes[targetIndex + 1].getWorldPosition();
- targetPos.set((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2, (pos1.z + pos2.z) / 2);
- newNodeIsIdiom[targetIndex] = true;
- newNodeIsIdiom[targetIndex + 1] = true;
- }
- break;
- }
- case 3:
- {
- // 找到连续三个空位
- for (let i = 0; i < container.unlock_Num - 2; i++) {
- if (!newNodeIsIdiom[i] && !newNodeIsIdiom[i + 1] && !newNodeIsIdiom[i + 2]) {
- targetIndex = i;
- break;
- }
- }
- if (targetIndex !== -1) {
- const pos1 = container.nodes[targetIndex].getWorldPosition();
- const pos2 = container.nodes[targetIndex + 1].getWorldPosition();
- const pos3 = container.nodes[targetIndex + 2].getWorldPosition();
- targetPos.set((pos1.x + pos2.x + pos3.x) / 3, (pos1.y + pos2.y + pos3.y) / 3, (pos1.z + pos2.z + pos3.z) / 3);
- newNodeIsIdiom[targetIndex] = true;
- newNodeIsIdiom[targetIndex + 1] = true;
- newNodeIsIdiom[targetIndex + 2] = true;
- }
- break;
- }
- default:
- return;
- } // 移动 Cube_Infor 到目标位置
- if (targetIndex !== -1) {
- tween(cube.node).to(0.3, {
- position: new Vec3(targetPos.x, targetPos.y, targetPos.z + 0.4)
- }).start();
- newIdiomCombine.set(cube, targetIndex); // 更新新映射
- }
- } // 更新 container 状态
- container.node_isIdiom = newNodeIsIdiom;
- container.idiom_combine = newIdiomCombine;
- console.log("调整后的容器状态:", container.node_isIdiom);
- console.log("更新后的 idiom_combine:", [...container.idiom_combine.entries()]);
- }
- async UnLock(node) {
- const res = await chsdk.playRewardAd('解锁槽位');
- if (res) {
- for (let i = 0; i < 2; i++) {
- if (this.Container.Lock_node[i].active) {
- this.Container.Lock_node[i].active = false;
- this.Container.unlock_Num += 1;
- (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
- error: Error()
- }), UI_Main) : UI_Main).evt.emit((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
- error: Error()
- }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
- error: Error()
- }), UI_Main) : UI_Main).evt.key.resume);
- return;
- }
- }
- (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
- error: Error()
- }), ch) : ch).audio.resume();
- }
- }
- playAnim() {
- const skeleton = this.Container.skeleton1.getComponent(sp.Skeleton); // 播放 anim_2, anim_3, anim_4,同时使用不同的轨道
- skeleton.setAnimation(0, 'anim_2', false);
- skeleton.setAnimation(1, 'anim_3', false);
- skeleton.setAnimation(2, 'anim_4', false); // 监听所有轨道完成,最后播放 anim_1
- let completedTracks = new Set();
- skeleton.setCompleteListener(trackEntry => {
- completedTracks.add(trackEntry.trackIndex); // 将完成的轨道加入记录
- console.log(`轨道 ${trackEntry.trackIndex} 的动画完成`); // 如果轨道 0、1、2 都完成,则播放 anim_1
- if (completedTracks.has(0) && completedTracks.has(1) && completedTracks.has(2)) {
- console.log('所有动画完成,播放 anim_1'); // 播放 anim_1 并监听其完成事件
- skeleton.setAnimation(0, 'anim_1', false); // 非循环播放 anim_1
- skeleton.setCompleteListener(trackEntry => {
- if (trackEntry.animation.name === 'anim_1') {
- console.log('anim_1 播放完成');
- skeleton.setCompleteListener(null); // 移除监听器,防止重复触发
- }
- });
- }
- });
- }
- }, _class3.instance = null, _class3), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "camera", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return null;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "Ani", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return [];
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "Mid", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return [];
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=67f356369ce567fe1898b7ae72038ee83758a446.js.map
|