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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } 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() { super(...arguments); _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 (var i = 0; i < 10; i++) { var newCube = instantiate(this.prefab); newCube.active = true; // 初始时设置为非激活状态 // 按顺序为节点赋值文字内容 var idiomIndex = Math.floor(i / 2); var 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() { var cube = this.Cube_Pool.get(); if (cube) cube.active = true; return cube; } // 将方块回收到对象池 recycleCube(cube) { cube.active = false; // 将方块设置为非激活状态 this.Cube_Pool.put(cube); } //合成规则导入 start() { if (!find('Container').getComponent(Container_Manager)) { find('Container').getComponent(Container_Manager) = 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) { var _this = this; if (this.idiom_combine.size < 2) { return false; // 至少需要两个方块 } var _loop = function _loop(cube) { // 遍历 idioms 列表,检查是否匹配成语 var 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 { v: true }; } // 再检查逆序组合是否匹配 var 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 { v: true }; } }, _ret; for (var cube of this.idiom_combine.keys()) { _ret = _loop(cube); if (_ret) return _ret.v; } return false; // 没有匹配到成语 } level_idioms() { var _this2 = this; return _asyncToGenerator(function* () { // 筛选满足条件的元素 var validConfig = _this2.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 (var i = 0; i < 5;) { var rand = (_crd && ch_util === void 0 ? (_reportPossibleCrUseOfch_util({ error: Error() }), ch_util) : ch_util).getRandomInt(0, validConfig.length - 1); // 使用 indexOf 检查是否已存在 if (_this2.index.indexOf(rand) === -1) { _this2.index[i] = rand; _this2.idioms[i] = validConfig[rand]; i++; } } } yield (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).show(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({ error: Error() }), UI_Idioms) : UI_Idioms); yield _this2.instantiateCube(); yield _this2.create_node.nodeMoving(); })(); } //消除一组 eliminate() { var _this3 = this; //先判断槽内是否有方块,如果有,匹配槽内最前面一个与散落方块中的 var cube; for (var [key, value] of this.idiom_combine) { if (value === 0) { cube = key; break; } } //槽中有方块 if (cube) { var originalReferences = [...this.nodeReferences]; var _loop2 = function _loop2(element) { if (_this3.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; var 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); _this3.nodeReferences = _this3.nodeReferences.filter(el => el !== element && el !== cube.node); return 0; // break } else if (_this3.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; var _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)); _this3.nodeReferences = _this3.nodeReferences.filter(el => el !== element && el !== cube.node); return 0; // break } }, _ret2; for (var element of originalReferences) { _ret2 = _loop2(element); if (_ret2 === 0) break; } } //槽中没有方块 else { var flag = false; var originalReferences1 = [...this.nodeReferences]; var originalReferences2 = [...this.nodeReferences]; var _loop3 = function _loop3(element1) { var _loop4 = function _loop4(element2) { if (_this3.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; var 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)); _this3.nodeReferences = _this3.nodeReferences.filter(el => el !== element1 && el !== element2); flag = true; return 0; // break } if (_this3.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; var _targetRotation2 = new Quat(); Quat.fromEuler(_targetRotation2, -90, 0, 0); element1.rotation = _targetRotation2; 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 = _targetRotation2; // 使用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)); _this3.nodeReferences = _this3.nodeReferences.filter(el => el !== element1 && el !== element2); flag = true; return 0; // break } }, _ret3; for (var element2 of originalReferences2) { _ret3 = _loop4(element2); if (_ret3 === 0) break; } if (flag === true) { return 1; // break } }; for (var element1 of originalReferences1) { if (_loop3(element1)) break; } } } shuffle() { var _this4 = this; return _asyncToGenerator(function* () { // 回收所有非槽内的活跃节点 _this4.nodeReferences.forEach(node => { var 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) { _this4.recycleCube(node); // 回收到池中 } }); // 等待节点移动完成后执行后续逻辑 yield _this4.create_node.nodeMoving(); })(); } //清空槽子 Empty() { for (var 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 initializer() { return null; } }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "create_node", [_dec3], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return null; } }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "nodes", [_dec4], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return []; } })), _class2)) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=62164bffde26a064612116b1cf2a16a8b180acda.js.map