System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7"], function (_export, _context) { "use strict"; var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, BoxCollider, Component, instantiate, Node, NodePool, Prefab, Quat, RigidBody, table_idiom, ch_util, CreateIdiom, Cube_Infor, Cube_State, UI_Idioms, gui, GameCtl, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _class3, _crd, ccclass, property, Container_Manager; 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 _reportPossibleCrUseOftable_idiom(extras) { _reporterNs.report("table_idiom", "../module_extra/table_ts/table_idiom", _context.meta, extras); } function _reportPossibleCrUseOfch_util(extras) { _reporterNs.report("ch_util", "../ch/ch_util", _context.meta, extras); } function _reportPossibleCrUseOfCreateIdiom(extras) { _reporterNs.report("CreateIdiom", "./CreateIdiom", _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_Idioms(extras) { _reporterNs.report("UI_Idioms", "../module_game/ui/UI_Idioms/UI_Idioms", _context.meta, extras); } function _reportPossibleCrUseOfgui(extras) { _reporterNs.report("gui", "../core/ui/ui", _context.meta, extras); } function _reportPossibleCrUseOfGameCtl(extras) { _reporterNs.report("GameCtl", "./GameCtl", _context.meta, extras); } return { setters: [function (_unresolved_) { _reporterNs = _unresolved_; }, function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; _decorator = _cc._decorator; BoxCollider = _cc.BoxCollider; Component = _cc.Component; instantiate = _cc.instantiate; Node = _cc.Node; NodePool = _cc.NodePool; Prefab = _cc.Prefab; Quat = _cc.Quat; RigidBody = _cc.RigidBody; }, function (_unresolved_2) { table_idiom = _unresolved_2.table_idiom; }, function (_unresolved_3) { ch_util = _unresolved_3.default; }, function (_unresolved_4) { CreateIdiom = _unresolved_4.CreateIdiom; }, function (_unresolved_5) { Cube_Infor = _unresolved_5.Cube_Infor; Cube_State = _unresolved_5.Cube_State; }, function (_unresolved_6) { UI_Idioms = _unresolved_6.UI_Idioms; }, function (_unresolved_7) { gui = _unresolved_7.gui; }, function (_unresolved_8) { GameCtl = _unresolved_8.GameCtl; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "e84de8IXbZDjZbYlbQpevuI", "Container_Manager", undefined); __checkObsolete__(['_decorator', 'BoxCollider', 'Component', 'instantiate', 'Node', 'NodePool', 'Prefab', 'Quat', 'random', 'RigidBody']); ({ ccclass, property } = _decorator); _export("Container_Manager", Container_Manager = (_dec = ccclass('Container_Manager'), _dec2 = property(Prefab), _dec3 = property(_crd && CreateIdiom === void 0 ? (_reportPossibleCrUseOfCreateIdiom({ error: Error() }), CreateIdiom) : CreateIdiom), _dec4 = property([Node]), _dec(_class = (_class2 = (_class3 = class Container_Manager extends Component { constructor(...args) { super(...args); _initializerDefineProperty(this, "prefab", _descriptor, this); this.config = null; //成语库 this.idioms = []; //生成的成语 this.index = []; //生成的成语角标,避免生成重复成语 _initializerDefineProperty(this, "create_node", _descriptor2, this); _initializerDefineProperty(this, "nodes", _descriptor3, this); //位置节点 用于成语放入 this.node_isIdiom = new Array(10).fill(false); this.idiom_combine = new Map(); this.Cube_Pool = new NodePool(); this.nodeReferences = []; } // 额外维护的节点引用数组 instantiateCube() { for (let i = 0; i < 10; i++) { const newCube = instantiate(this.prefab); newCube.active = true; // 初始时设置为非激活状态 // 按顺序为节点赋值文字内容 let idiomIndex = Math.floor(i / 2); let isPiece1 = i % 2 === 0; newCube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text = isPiece1 ? this.idioms[idiomIndex].piece_1_word : this.idioms[idiomIndex].piece_2_word; console.log("生成第" + i + "个节点:" + newCube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text); this.Cube_Pool.put(newCube); } } getCube() { const cube = this.Cube_Pool.get(); if (cube) cube.active = true; return cube; } // 将方块回收到对象池 recycleCube(cube) { cube.active = false; // 将方块设置为非激活状态 this.Cube_Pool.put(cube); } //合成规则导入 start() { if (!Container_Manager.instance) { Container_Manager.instance = this; } this.config = (_crd && table_idiom === void 0 ? (_reportPossibleCrUseOftable_idiom({ error: Error() }), table_idiom) : table_idiom).getList(); if (this.config.length === 95) { console.log("合成规则导入成功"); } this.level_idioms(); } update(deltaTime) {} checkIdiom_Combine(matchedcube2, outMatchedCubes) { if (this.idiom_combine.size < 2) { return false; // 至少需要两个方块 } for (let cube of this.idiom_combine.keys()) { // 遍历 idioms 列表,检查是否匹配成语 const matchedIdiom = this.idioms.find(idiom => idiom.piece_1_word === cube.Text && idiom.piece_2_word === matchedcube2.Text); if (matchedIdiom) { // 匹配成功 outMatchedCubes.push(cube, matchedcube2); this.nodeReferences = this.nodeReferences.filter(el => el !== matchedcube2.node && el !== cube.node); console.log("成功拼成成语: " + matchedIdiom.piece_1_word + matchedIdiom.piece_2_word); return true; } // 再检查逆序组合是否匹配 const reverseMatchedIdiom = this.idioms.find(idiom => idiom.piece_1_word === matchedcube2.Text && idiom.piece_2_word === cube.Text); if (reverseMatchedIdiom) { // 匹配成功 outMatchedCubes.push(matchedcube2, cube); this.nodeReferences = this.nodeReferences.filter(el => el !== matchedcube2.node && el !== cube.node); console.log("成功拼成成语: " + reverseMatchedIdiom.piece_1_word + reverseMatchedIdiom.piece_2_word); return true; } } return false; // 没有匹配到成语 } async level_idioms() { // 筛选满足条件的元素 let validConfig = this.config.filter(item => (item.idiom_type === "一" || item.idiom_type === "二") && ( // 可以加多个条件 item.piece_1_word === "一" || item.piece_2_word === "二") // 可以加多个筛选条件 ); if (validConfig.length < 5) { console.error("满足条件的成语数量不足 5 个"); } else { // 从筛选结果中随机选择 for (let i = 0; i < 5;) { let rand = (_crd && ch_util === void 0 ? (_reportPossibleCrUseOfch_util({ error: Error() }), ch_util) : ch_util).getRandomInt(0, validConfig.length - 1); // 使用 indexOf 检查是否已存在 if (this.index.indexOf(rand) === -1) { this.index[i] = rand; this.idioms[i] = validConfig[rand]; i++; } } } await (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).show(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({ error: Error() }), UI_Idioms) : UI_Idioms); await this.instantiateCube(); await this.create_node.nodeMoving(); } //消除一组 eliminate() { //先判断槽内是否有方块,如果有,匹配槽内最前面一个与散落方块中的 let cube; for (const [key, value] of this.idiom_combine) { if (value === 0) { cube = key; break; } } //槽中有方块 if (cube) { const originalReferences = [...this.nodeReferences]; for (const element of originalReferences) { if (this.idioms.find(c => c.idiom == element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text + cube.Text) && element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor) !== cube) { console.log(element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text); element.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; element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; element.getComponent(BoxCollider).enabled = false; let targetRotation = new Quat(); Quat.fromEuler(targetRotation, -90, 0, 0); element.rotation = targetRotation; // 使用filter过滤掉当前元素 (_crd && GameCtl === void 0 ? (_reportPossibleCrUseOfGameCtl({ error: Error() }), GameCtl) : GameCtl).instance.combine_ani(element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor), cube); this.nodeReferences = this.nodeReferences.filter(el => el !== element && el !== cube.node); break; } else if (this.idioms.find(c => c.idiom == cube.Text + element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text) && element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor) !== cube) { console.log(element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text); element.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; element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; element.getComponent(BoxCollider).enabled = false; let targetRotation = new Quat(); Quat.fromEuler(targetRotation, -90, 0, 0); element.rotation = targetRotation; (_crd && GameCtl === void 0 ? (_reportPossibleCrUseOfGameCtl({ error: Error() }), GameCtl) : GameCtl).instance.combine_ani(cube, element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor)); this.nodeReferences = this.nodeReferences.filter(el => el !== element && el !== cube.node); break; } } } //槽中没有方块 else { let flag = false; const originalReferences1 = [...this.nodeReferences]; const originalReferences2 = [...this.nodeReferences]; for (const element1 of originalReferences1) { for (const element2 of originalReferences2) { if (this.idioms.find(c => c.idiom == element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text + element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text)) { element1.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; element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; let targetRotation = new Quat(); Quat.fromEuler(targetRotation, -90, 0, 0); element1.rotation = targetRotation; element2.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; element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; element2.getComponent(BoxCollider).enabled = false; element2.rotation = targetRotation; // 使用filter过滤掉当前元素 (_crd && GameCtl === void 0 ? (_reportPossibleCrUseOfGameCtl({ error: Error() }), GameCtl) : GameCtl).instance.combine_ani(element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor), element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor)); this.nodeReferences = this.nodeReferences.filter(el => el !== element1 && el !== element2); flag = true; break; } if (this.idioms.find(c => c.idiom == element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text + element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).Text)) { element1.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; element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; let targetRotation = new Quat(); Quat.fromEuler(targetRotation, -90, 0, 0); element1.rotation = targetRotation; element2.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; element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; element2.getComponent(BoxCollider).enabled = false; element2.rotation = targetRotation; // 使用filter过滤掉当前元素 (_crd && GameCtl === void 0 ? (_reportPossibleCrUseOfGameCtl({ error: Error() }), GameCtl) : GameCtl).instance.combine_ani(element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor), element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor)); this.nodeReferences = this.nodeReferences.filter(el => el !== element1 && el !== element2); flag = true; break; } } if (flag === true) { break; } } } } async shuffle() { // 回收所有非槽内的活跃节点 this.nodeReferences.forEach(node => { const cubeInfo = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({ error: Error() }), Cube_Infor) : Cube_Infor); if (cubeInfo.state === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({ error: Error() }), Cube_State) : Cube_State).live) { this.recycleCube(node); // 回收到池中 } }); // 等待节点移动完成后执行后续逻辑 await this.create_node.nodeMoving(); } //清空槽子 Empty() { for (let idiom of this.idiom_combine.keys()) { idiom.rigidbody.type = RigidBody.Type.DYNAMIC; idiom.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({ error: Error() }), Cube_State) : Cube_State).live; idiom.node.position = this.create_node.node.position; } this.idiom_combine.clear(); this.node_isIdiom.fill(false); (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({ error: Error() }), UI_Idioms) : UI_Idioms).all_light_Hide(); } }, _class3.instance = null, _class3), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "prefab", [_dec2], { configurable: true, enumerable: true, writable: true, initializer: function () { return null; } }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "create_node", [_dec3], { configurable: true, enumerable: true, writable: true, initializer: function () { return null; } }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "nodes", [_dec4], { configurable: true, enumerable: true, writable: true, initializer: function () { return []; } })), _class2)) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=7f6a12ecc1a0c40226d8c35daa4b84136b1bf590.js.map