90cb08bdd2589bd4780881bf755dafe0306918a1.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. 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", "__unresolved_12", "__unresolved_13", "__unresolved_14", "__unresolved_15"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, BoxCollider, Component, director, instantiate, Node, NodePool, Prefab, Quat, RigidBody, tween, Vec3, ch_util, gui, UI_Main, CreateIdiom, Cube_Infor, Cube_State, GameCtl, ch, table_idiom_order, table_idiom_unorder_1_3, table_idiom_unorder_2_2, table_idiom_unorder_3_1, table_level, table_level_2, GameState, Hall, UI_Idioms, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _crd, ccclass, property, Container_Manager;
  4. 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); } }
  5. 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); }); }; }
  6. 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 }); }
  7. 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; }
  8. 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.'); }
  9. function _reportPossibleCrUseOfch_util(extras) {
  10. _reporterNs.report("ch_util", "../../ch/ch_util", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfgui(extras) {
  13. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfLayout_Main(extras) {
  16. _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfUI_Main(extras) {
  19. _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras);
  20. }
  21. function _reportPossibleCrUseOfCreateIdiom(extras) {
  22. _reporterNs.report("CreateIdiom", "./CreateIdiom", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfCube_Infor(extras) {
  25. _reporterNs.report("Cube_Infor", "./Cube_Infor", _context.meta, extras);
  26. }
  27. function _reportPossibleCrUseOfCube_State(extras) {
  28. _reporterNs.report("Cube_State", "./Cube_Infor", _context.meta, extras);
  29. }
  30. function _reportPossibleCrUseOfGameCtl(extras) {
  31. _reporterNs.report("GameCtl", "./GameCtl", _context.meta, extras);
  32. }
  33. function _reportPossibleCrUseOfch(extras) {
  34. _reporterNs.report("ch", "../../ch/ch", _context.meta, extras);
  35. }
  36. function _reportPossibleCrUseOftable_idiom_order(extras) {
  37. _reporterNs.report("table_idiom_order", "../../module_extra/table_ts/table_idiom_order", _context.meta, extras);
  38. }
  39. function _reportPossibleCrUseOftable_idiom_unorder_1_(extras) {
  40. _reporterNs.report("table_idiom_unorder_1_3", "../../module_extra/table_ts/table_idiom_unorder_1_3", _context.meta, extras);
  41. }
  42. function _reportPossibleCrUseOftable_idiom_unorder_2_(extras) {
  43. _reporterNs.report("table_idiom_unorder_2_2", "../../module_extra/table_ts/table_idiom_unorder_2_2", _context.meta, extras);
  44. }
  45. function _reportPossibleCrUseOftable_idiom_unorder_3_(extras) {
  46. _reporterNs.report("table_idiom_unorder_3_1", "../../module_extra/table_ts/table_idiom_unorder_3_1", _context.meta, extras);
  47. }
  48. function _reportPossibleCrUseOftable_level(extras) {
  49. _reporterNs.report("table_level", "../../module_extra/table_ts/table_level", _context.meta, extras);
  50. }
  51. function _reportPossibleCrUseOftable_level_(extras) {
  52. _reporterNs.report("table_level_2", "../../module_extra/table_ts/table_level_2", _context.meta, extras);
  53. }
  54. function _reportPossibleCrUseOfGameState(extras) {
  55. _reporterNs.report("GameState", "../hall/Hall", _context.meta, extras);
  56. }
  57. function _reportPossibleCrUseOfHall(extras) {
  58. _reporterNs.report("Hall", "../hall/Hall", _context.meta, extras);
  59. }
  60. function _reportPossibleCrUseOfUI_Idioms(extras) {
  61. _reporterNs.report("UI_Idioms", "../ui/UI_Idioms/UI_Idioms", _context.meta, extras);
  62. }
  63. return {
  64. setters: [function (_unresolved_) {
  65. _reporterNs = _unresolved_;
  66. }, function (_cc) {
  67. _cclegacy = _cc.cclegacy;
  68. __checkObsolete__ = _cc.__checkObsolete__;
  69. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  70. _decorator = _cc._decorator;
  71. BoxCollider = _cc.BoxCollider;
  72. Component = _cc.Component;
  73. director = _cc.director;
  74. instantiate = _cc.instantiate;
  75. Node = _cc.Node;
  76. NodePool = _cc.NodePool;
  77. Prefab = _cc.Prefab;
  78. Quat = _cc.Quat;
  79. RigidBody = _cc.RigidBody;
  80. tween = _cc.tween;
  81. Vec3 = _cc.Vec3;
  82. }, function (_unresolved_2) {
  83. ch_util = _unresolved_2.default;
  84. }, function (_unresolved_3) {
  85. gui = _unresolved_3.gui;
  86. }, function (_unresolved_4) {
  87. UI_Main = _unresolved_4.UI_Main;
  88. }, function (_unresolved_5) {
  89. CreateIdiom = _unresolved_5.CreateIdiom;
  90. }, function (_unresolved_6) {
  91. Cube_Infor = _unresolved_6.Cube_Infor;
  92. Cube_State = _unresolved_6.Cube_State;
  93. }, function (_unresolved_7) {
  94. GameCtl = _unresolved_7.GameCtl;
  95. }, function (_unresolved_8) {
  96. ch = _unresolved_8.ch;
  97. }, function (_unresolved_9) {
  98. table_idiom_order = _unresolved_9.table_idiom_order;
  99. }, function (_unresolved_10) {
  100. table_idiom_unorder_1_3 = _unresolved_10.table_idiom_unorder_1_3;
  101. }, function (_unresolved_11) {
  102. table_idiom_unorder_2_2 = _unresolved_11.table_idiom_unorder_2_2;
  103. }, function (_unresolved_12) {
  104. table_idiom_unorder_3_1 = _unresolved_12.table_idiom_unorder_3_1;
  105. }, function (_unresolved_13) {
  106. table_level = _unresolved_13.table_level;
  107. }, function (_unresolved_14) {
  108. table_level_2 = _unresolved_14.table_level_2;
  109. }, function (_unresolved_15) {
  110. GameState = _unresolved_15.GameState;
  111. Hall = _unresolved_15.Hall;
  112. }, function (_unresolved_16) {
  113. UI_Idioms = _unresolved_16.UI_Idioms;
  114. }],
  115. execute: function () {
  116. _crd = true;
  117. _cclegacy._RF.push({}, "e84de8IXbZDjZbYlbQpevuI", "Container_Manager", undefined);
  118. __checkObsolete__(['_decorator', 'BoxCollider', 'Component', 'director', 'find', 'instantiate', 'Node', 'NodePool', 'Prefab', 'Quat', 'random', 'RigidBody', 'sp', 'tween', 'Vec3']);
  119. ({
  120. ccclass,
  121. property
  122. } = _decorator);
  123. _export("Container_Manager", Container_Manager = (_dec = ccclass('Container_Manager'), _dec2 = property(Node), _dec3 = property(Node), _dec4 = property([Node]), _dec5 = property([Prefab]), _dec6 = property(_crd && CreateIdiom === void 0 ? (_reportPossibleCrUseOfCreateIdiom({
  124. error: Error()
  125. }), CreateIdiom) : CreateIdiom), _dec7 = property([Node]), _dec(_class = (_class2 = class Container_Manager extends Component {
  126. constructor() {
  127. super(...arguments);
  128. _initializerDefineProperty(this, "skeleton1", _descriptor, this);
  129. _initializerDefineProperty(this, "skeleton2", _descriptor2, this);
  130. this.canTouch = false;
  131. _initializerDefineProperty(this, "Lock_node", _descriptor3, this);
  132. _initializerDefineProperty(this, "prefabs", _descriptor4, this);
  133. this.level_config = null;
  134. //关卡配置
  135. this.level2_config = null;
  136. //第二关配置
  137. this.config = null;
  138. //有规律的成语库
  139. this.config_1_3 = null;
  140. //无规律1+3
  141. this.config_2_2 = null;
  142. //无规律2+2
  143. this.config_3_1 = null;
  144. //无规律3+1
  145. this.idioms = [];
  146. //生成的成语
  147. this.idioms_Copy = [];
  148. //生成的成语备份
  149. this.index = 0;
  150. _initializerDefineProperty(this, "create_node", _descriptor5, this);
  151. _initializerDefineProperty(this, "nodes", _descriptor6, this);
  152. //位置节点 用于成语放入
  153. this.node_isIdiom = new Array(9).fill(false);
  154. this.unlock_Num = 7;
  155. this.is_Show_UI_Lock = false;
  156. this.idiom_combine = new Map();
  157. this.Cube_Pool = new NodePool();
  158. this.nodeReferences = [];
  159. // 额外维护的节点引用数组
  160. this.count = 0;
  161. this.time = 0;
  162. }
  163. instantiateCube() {
  164. var num = 60;
  165. if (this.idioms.length < 30) {
  166. num = this.idioms.length * 2;
  167. }
  168. for (var i = 0; i < num; i++) {
  169. var idiomIndex = Math.floor(i / 2);
  170. var isPiece1 = i % 2 === 0;
  171. var Text_Length = isPiece1 ? this.idioms[idiomIndex].piece_1_word.length : this.idioms[idiomIndex].piece_2_word.length;
  172. var newCube = instantiate(this.prefabs[Text_Length - 1]);
  173. newCube.active = true; // 按顺序为节点赋值文字内容
  174. newCube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  175. error: Error()
  176. }), Cube_Infor) : Cube_Infor).Text = isPiece1 ? this.idioms[idiomIndex].piece_1_word : this.idioms[idiomIndex].piece_2_word; // console.log("生成第" + i + "个节点:" + newCube.getComponent(Cube_Infor).Text);
  177. this.Cube_Pool.put(newCube);
  178. }
  179. this.index = num;
  180. if ((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  181. error: Error()
  182. }), Hall) : Hall).getInstance().player.get_max_floor() != 0) this.shufflePool();
  183. }
  184. instantiateNewCube() {
  185. console.log("instantiateNewCube");
  186. if (this.index < this.count * 2) {
  187. console.log("idiomIndex:" + Math.floor(this.index / 2));
  188. var idiomIndex = Math.floor(this.index / 2);
  189. var isPiece1 = this.index % 2 === 0;
  190. var Text_Length = isPiece1 ? this.idioms_Copy[idiomIndex].piece_1_word.length : this.idioms_Copy[idiomIndex].piece_2_word.length;
  191. var newCube = instantiate(this.prefabs[Text_Length - 1]);
  192. newCube.active = true; // 按顺序为节点赋值文字内容
  193. newCube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  194. error: Error()
  195. }), Cube_Infor) : Cube_Infor).Text = isPiece1 ? this.idioms_Copy[idiomIndex].piece_1_word : this.idioms_Copy[idiomIndex].piece_2_word; //随机选择已在nodereference中的一个方块position
  196. newCube.parent = director.getScene();
  197. newCube.setPosition(this.nodeReferences[Math.floor(Math.random() * this.nodeReferences.length)].position.x, this.nodeReferences[Math.floor(Math.random() * this.nodeReferences.length)].position.y - 0.1, this.nodeReferences[Math.floor(Math.random() * this.nodeReferences.length)].position.z);
  198. this.nodeReferences.push(newCube);
  199. console.log("生成第" + this.index + "个节点:" + newCube.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  200. error: Error()
  201. }), Cube_Infor) : Cube_Infor).Text);
  202. console.log("位置:" + newCube.position);
  203. this.index = this.index + 1;
  204. }
  205. }
  206. getCube() {
  207. // console.log(this.Cube_Pool.size());
  208. var cube = this.Cube_Pool.get();
  209. if (cube) cube.active = true;
  210. return cube;
  211. } // 将方块回收到对象池
  212. recycleCube(cube) {
  213. cube.active = false; // 将方块设置为非激活状态
  214. this.Cube_Pool.put(cube);
  215. } //清空对象池
  216. clearCubePool() {
  217. this.Cube_Pool.clear();
  218. } //合成规则导入
  219. start() {
  220. this.config = (_crd && table_idiom_order === void 0 ? (_reportPossibleCrUseOftable_idiom_order({
  221. error: Error()
  222. }), table_idiom_order) : table_idiom_order).getList();
  223. this.config_1_3 = (_crd && table_idiom_unorder_1_3 === void 0 ? (_reportPossibleCrUseOftable_idiom_unorder_1_({
  224. error: Error()
  225. }), table_idiom_unorder_1_3) : table_idiom_unorder_1_3).getList();
  226. this.config_2_2 = (_crd && table_idiom_unorder_2_2 === void 0 ? (_reportPossibleCrUseOftable_idiom_unorder_2_({
  227. error: Error()
  228. }), table_idiom_unorder_2_2) : table_idiom_unorder_2_2).getList();
  229. this.config_3_1 = (_crd && table_idiom_unorder_3_1 === void 0 ? (_reportPossibleCrUseOftable_idiom_unorder_3_({
  230. error: Error()
  231. }), table_idiom_unorder_3_1) : table_idiom_unorder_3_1).getList();
  232. console.log(this.config.length);
  233. console.log(this.config_1_3.length);
  234. console.log(this.config_2_2.length);
  235. console.log(this.config_3_1.length);
  236. this.level_config = (_crd && table_level === void 0 ? (_reportPossibleCrUseOftable_level({
  237. error: Error()
  238. }), table_level) : table_level).getList();
  239. this.level2_config = (_crd && table_level_2 === void 0 ? (_reportPossibleCrUseOftable_level_({
  240. error: Error()
  241. }), table_level_2) : table_level_2).getList(); // if (this.level_config.length === 5) {
  242. // console.log("关卡配置导入成功");
  243. // }
  244. this.level_idioms();
  245. }
  246. update(deltaTime) {}
  247. checkIdiom_Combine(matchedcube2, outMatchedCubes) {
  248. var _this = this;
  249. if (this.idiom_combine.size < 2) {
  250. return false; // 至少需要两个方块
  251. }
  252. var _loop = function _loop(cube) {
  253. // 遍历 idioms 列表,检查是否匹配成语
  254. var matchedIdiom = _this.idioms.find(idiom => idiom.piece_1_word === cube.Text && idiom.piece_2_word === matchedcube2.Text);
  255. if (matchedIdiom) {
  256. // 匹配成功
  257. outMatchedCubes.push(cube, matchedcube2);
  258. _this.nodeReferences = _this.nodeReferences.filter(el => el !== matchedcube2.node && el !== cube.node);
  259. console.log("成功拼成成语: " + matchedIdiom.piece_1_word + matchedIdiom.piece_2_word);
  260. return {
  261. v: true
  262. };
  263. } // 再检查逆序组合是否匹配
  264. var reverseMatchedIdiom = _this.idioms.find(idiom => idiom.piece_1_word === matchedcube2.Text && idiom.piece_2_word === cube.Text);
  265. if (reverseMatchedIdiom) {
  266. // 匹配成功
  267. outMatchedCubes.push(matchedcube2, cube);
  268. _this.nodeReferences = _this.nodeReferences.filter(el => el !== matchedcube2.node && el !== cube.node);
  269. console.log("成功拼成成语: " + reverseMatchedIdiom.piece_1_word + reverseMatchedIdiom.piece_2_word);
  270. return {
  271. v: true
  272. };
  273. }
  274. },
  275. _ret;
  276. for (var cube of this.idiom_combine.keys()) {
  277. _ret = _loop(cube);
  278. if (_ret) return _ret.v;
  279. }
  280. return false; // 没有匹配到成语
  281. }
  282. level_idioms() {
  283. var _this2 = this;
  284. return _asyncToGenerator(function* () {
  285. _this2.Lock_node.forEach(node => node.active = true);
  286. _this2.unlock_Num = 7;
  287. _this2.is_Show_UI_Lock = false;
  288. _this2.canTouch = false;
  289. _this2.index = 0;
  290. var level = (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  291. error: Error()
  292. }), Hall) : Hall).getInstance().player.get_max_floor();
  293. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  294. error: Error()
  295. }), Hall) : Hall).getInstance().gameState = (_crd && GameState === void 0 ? (_reportPossibleCrUseOfGameState({
  296. error: Error()
  297. }), GameState) : GameState).gameing;
  298. if (level > 0) {
  299. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  300. error: Error()
  301. }), Hall) : Hall).getInstance().firstEnter = false;
  302. }
  303. _this2.clearLevelData();
  304. _this2.idioms = [];
  305. _this2.node_isIdiom = new Array(9).fill(false);
  306. _this2.idiom_combine = new Map(); // 获取当前关卡的成语配置
  307. if (level === 0) {
  308. _this2.setupLevel1();
  309. } else if (level === 1) {
  310. _this2.setupLevel2();
  311. } else {
  312. _this2.setupLevelDefault(level);
  313. }
  314. _this2.idioms_Copy = [..._this2.idioms];
  315. _this2.count = _this2.level_config[level].total;
  316. _this2.time = _this2.level_config[level].time;
  317. yield _this2.instantiateCube();
  318. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  319. error: Error()
  320. }), gui) : gui).show(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
  321. error: Error()
  322. }), UI_Idioms) : UI_Idioms);
  323. _this2.create_node.nodeMoving();
  324. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  325. error: Error()
  326. }), gui) : gui).show(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  327. error: Error()
  328. }), UI_Main) : UI_Main);
  329. })();
  330. }
  331. clearLevelData() {
  332. for (var node of this.nodeReferences) {
  333. node.destroy();
  334. }
  335. this.nodeReferences = [];
  336. this.clearCubePool();
  337. }
  338. setupLevel1() {
  339. var idiom_type_2 = this.level_config[0].idiom_type_2.split("_");
  340. console.log("idiom_type_2:", idiom_type_2);
  341. idiom_type_2.forEach(rule => {
  342. var filteredIdioms = this.config.filter(item => item.piece_2_word === rule);
  343. console.log("\u7B5B\u90092 " + rule + " \u540E\u7684\u6210\u8BED\uFF1A", filteredIdioms);
  344. this.idioms.push(...filteredIdioms);
  345. });
  346. console.log("最终选中的成语:", this.idioms);
  347. }
  348. setupLevel2() {
  349. for (var i = 0; i < 30; i++) {
  350. this.idioms.push(...this.filterIdioms(this.level2_config[i].idiom, this.config));
  351. this.idioms.push(...this.filterIdioms(this.level2_config[i].idiom, this.config_3_1));
  352. }
  353. for (var _i = 30; _i < 40; _i++) {
  354. this.idioms.push(...this.filterIdioms(this.level2_config[_i].idiom, this.config_2_2));
  355. }
  356. console.log("最终选中的成语:", this.idioms);
  357. }
  358. setupLevelDefault(level) {
  359. var dif = this.level_config[level].different_grade_level.split("_");
  360. var grade = dif[0];
  361. var idiom_type_1 = this.parseIdiomType(this.level_config[level].idiom_type_1);
  362. var idiom_type_2 = this.parseIdiomType(this.level_config[level].idiom_type_2);
  363. var count = this.level_config[level].count / (idiom_type_1.length + idiom_type_2.length);
  364. console.log("count:", count);
  365. var selectedIdioms = {}; // 筛选成语并随机选择
  366. this.selectIdiomsByRules(idiom_type_1, grade, count, selectedIdioms, 'piece_1_word');
  367. this.selectIdiomsByRules(idiom_type_2, grade, count, selectedIdioms, 'piece_2_word'); // 合并结果
  368. // 使用 Object.keys 来遍历 selectedIdioms
  369. for (var rule in selectedIdioms) {
  370. this.idioms.push(...selectedIdioms[rule]);
  371. } // 随机选择难度成语
  372. this.selectIdiomsByDifficulty(level, 'easy_1_3', this.config_1_3);
  373. this.selectIdiomsByDifficulty(level, 'hard_1_3', this.config_1_3);
  374. this.selectIdiomsByDifficulty(level, 'easy_2_2', this.config_2_2);
  375. this.selectIdiomsByDifficulty(level, 'hard_2_2', this.config_2_2);
  376. this.selectIdiomsByDifficulty(level, 'easy_3_1', this.config_3_1);
  377. this.selectIdiomsByDifficulty(level, 'hard_3_1', this.config_3_1);
  378. console.log("最终选中的成语:", this.idioms);
  379. }
  380. parseIdiomType(idiomType) {
  381. return idiomType.split("_").filter(item => item !== "");
  382. }
  383. selectIdiomsByRules(idiomType, grade, count, selectedIdioms, ruleKey) {
  384. idiomType.forEach(rule => {
  385. var filteredIdioms = this.config.filter(item => item[ruleKey] === rule && item.difficulty === grade);
  386. console.log("\u7B5B\u9009 " + rule + " \u540E\u7684\u6210\u8BED\uFF1A", filteredIdioms);
  387. if (filteredIdioms.length < count) {
  388. console.error("\u89C4\u5F8B " + rule + " \u7684\u6210\u8BED\u6570\u91CF\u4E0D\u8DB3\uFF0C\u4EC5\u6709 " + filteredIdioms.length + " \u4E2A");
  389. } else {
  390. var selected = this.randomSelectIdioms(filteredIdioms, count);
  391. selectedIdioms[rule] = selected;
  392. }
  393. });
  394. }
  395. randomSelectIdioms(filteredIdioms, count) {
  396. var selected = [];
  397. for (var i = 0; i < count; i++) {
  398. var rand = (_crd && ch_util === void 0 ? (_reportPossibleCrUseOfch_util({
  399. error: Error()
  400. }), ch_util) : ch_util).getRandomInt(0, filteredIdioms.length - 1);
  401. selected.push(filteredIdioms.splice(rand, 1)[0]);
  402. }
  403. return selected;
  404. }
  405. selectIdiomsByDifficulty(level, configKey, config) {
  406. if (this.level_config[level][configKey] > 0) {
  407. var filteredIdioms = config.filter(item => item.difficulty === "easy");
  408. for (var i = 0; i < this.level_config[level][configKey]; i++) {
  409. var rand = (_crd && ch_util === void 0 ? (_reportPossibleCrUseOfch_util({
  410. error: Error()
  411. }), ch_util) : ch_util).getRandomInt(0, filteredIdioms.length - 1);
  412. var selectedIdiom = filteredIdioms.splice(rand, 1)[0];
  413. this.idioms.push(selectedIdiom);
  414. }
  415. }
  416. }
  417. filterIdioms(idiom, config) {
  418. return config.filter(item => item.idiom === idiom);
  419. } // 精简后的消除一组函数
  420. eliminate() {
  421. var _find,
  422. _this3 = this;
  423. // 获取槽中的方块
  424. var cube = (_find = [...this.idiom_combine].find(_ref => {
  425. var [key, value] = _ref;
  426. return value === 0;
  427. })) == null ? void 0 : _find[0]; // 如果槽中有方块
  428. if (cube) {
  429. var originalReferences = [...this.nodeReferences];
  430. var _loop2 = function _loop2() {
  431. var elementCubeInfo = element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  432. error: Error()
  433. }), Cube_Infor) : Cube_Infor);
  434. var elementText = elementCubeInfo.Text;
  435. var cubeText = cube.Text;
  436. if (_this3.idioms.some(c => c.idiom === elementText + cubeText) && elementCubeInfo !== cube) {
  437. // 执行消除操作
  438. _this3.processElimination(element, cube);
  439. return 0; // break
  440. } else if (_this3.idioms.some(c => c.idiom === cubeText + elementText) && elementCubeInfo !== cube) {
  441. _this3.processElimination(cube, element);
  442. return 0; // break
  443. }
  444. },
  445. _ret2;
  446. for (var element of originalReferences) {
  447. _ret2 = _loop2();
  448. if (_ret2 === 0) break;
  449. }
  450. } else {
  451. var flag = false;
  452. var _originalReferences = [...this.nodeReferences];
  453. for (var element1 of _originalReferences) {
  454. var _loop3 = function _loop3() {
  455. var element1Text = element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  456. error: Error()
  457. }), Cube_Infor) : Cube_Infor).Text;
  458. var element2Text = element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  459. error: Error()
  460. }), Cube_Infor) : Cube_Infor).Text;
  461. if (_this3.idioms.some(c => c.idiom === element1Text + element2Text)) {
  462. // 执行消除操作
  463. _this3.processElimination(element1, element2);
  464. flag = true;
  465. return 0; // break
  466. } else if (_this3.idioms.some(c => c.idiom === element2Text + element1Text)) {
  467. // 执行消除操作
  468. _this3.processElimination(element2, element1);
  469. flag = true;
  470. return 0; // break
  471. }
  472. if (flag) {
  473. return 0; // break
  474. }
  475. },
  476. _ret3;
  477. for (var element2 of _originalReferences) {
  478. _ret3 = _loop3();
  479. if (_ret3 === 0) break;
  480. }
  481. if (flag) {
  482. for (var i = 0; i < 2; i++) this.instantiateNewCube();
  483. break;
  484. }
  485. }
  486. if (!flag) {
  487. console.log("没有可消除");
  488. }
  489. }
  490. } // 消除操作
  491. processElimination(element1, element2) {
  492. this.nodeReferences = this.nodeReferences.filter(el => el !== element1 && el !== element2);
  493. var element1CubeInfo = element1.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  494. error: Error()
  495. }), Cube_Infor) : Cube_Infor);
  496. var element2CubeInfo = element2.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  497. error: Error()
  498. }), Cube_Infor) : Cube_Infor);
  499. [element1, element2].forEach(element => {
  500. element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  501. error: Error()
  502. }), Cube_Infor) : Cube_Infor).state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  503. error: Error()
  504. }), Cube_State) : Cube_State).wait;
  505. element.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  506. error: Error()
  507. }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC;
  508. element.getComponent(BoxCollider).enabled = false;
  509. var targetRotation = new Quat();
  510. Quat.fromEuler(targetRotation, -90, 0, 0);
  511. element.rotation = targetRotation;
  512. }); // 执行动画
  513. (_crd && GameCtl === void 0 ? (_reportPossibleCrUseOfGameCtl({
  514. error: Error()
  515. }), GameCtl) : GameCtl).instance.combine_ani(element1CubeInfo, element2CubeInfo);
  516. }
  517. shuffle() {
  518. var _this4 = this;
  519. return _asyncToGenerator(function* () {
  520. // 回收所有非槽内的活跃节点
  521. _this4.nodeReferences.forEach(node => {
  522. var cubeInfo = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  523. error: Error()
  524. }), Cube_Infor) : Cube_Infor);
  525. if (cubeInfo.state === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  526. error: Error()
  527. }), Cube_State) : Cube_State).live) {
  528. var targetRotation = new Quat();
  529. Quat.fromEuler(targetRotation, -90, 0, 0);
  530. node.rotation = targetRotation;
  531. _this4.recycleCube(node); // 回收到池中
  532. }
  533. });
  534. _this4.shufflePool(); // 等待节点移动完成后执行后续逻辑
  535. _this4.create_node.nodeMoving();
  536. })();
  537. } //清空槽子
  538. Empty() {
  539. var _this5 = this;
  540. var _loop4 = function _loop4(idiom) {
  541. idiom.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  542. error: Error()
  543. }), Cube_State) : Cube_State).live;
  544. var posX = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  545. error: Error()
  546. }), ch) : ch).util.getRandom(-3, 3);
  547. var posZ = (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  548. error: Error()
  549. }), ch) : ch).util.getRandom(-3, 3);
  550. tween(idiom.node).to(0.2, {
  551. position: new Vec3(posX, _this5.create_node.node.position.y + 5, posZ)
  552. }).call(() => {
  553. idiom.rigidbody.type = RigidBody.Type.DYNAMIC;
  554. }).start(); //idiom.node.position = ;
  555. };
  556. for (var idiom of this.idiom_combine.keys()) {
  557. _loop4(idiom);
  558. }
  559. this.idiom_combine.clear();
  560. this.node_isIdiom.fill(false);
  561. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  562. error: Error()
  563. }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
  564. error: Error()
  565. }), UI_Idioms) : UI_Idioms).all_light_Hide();
  566. }
  567. AddTime() {
  568. var layout = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  569. error: Error()
  570. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  571. error: Error()
  572. }), UI_Main) : UI_Main).getLayout();
  573. layout.time += 120;
  574. }
  575. shufflePool() {
  576. var poolSize = this.Cube_Pool.size();
  577. var tempArray = []; // 从池中取出所有节点到临时数组
  578. for (var i = 0; i < poolSize; i++) {
  579. tempArray.push(this.Cube_Pool.get());
  580. } // 只打乱部分节点(以 30% 为例,可调整比例)
  581. var shuffleCount = Math.ceil(poolSize * 0.3); // 只打乱前 30%
  582. for (var _i2 = 0; _i2 < shuffleCount; _i2++) {
  583. var randomIndex = Math.floor(Math.random() * poolSize);
  584. [tempArray[_i2], tempArray[randomIndex]] = [tempArray[randomIndex], tempArray[_i2]];
  585. } // 将打乱的节点放回池中
  586. tempArray.forEach(cube => this.Cube_Pool.put(cube));
  587. }
  588. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "skeleton1", [_dec2], {
  589. configurable: true,
  590. enumerable: true,
  591. writable: true,
  592. initializer: function initializer() {
  593. return null;
  594. }
  595. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "skeleton2", [_dec3], {
  596. configurable: true,
  597. enumerable: true,
  598. writable: true,
  599. initializer: function initializer() {
  600. return null;
  601. }
  602. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "Lock_node", [_dec4], {
  603. configurable: true,
  604. enumerable: true,
  605. writable: true,
  606. initializer: function initializer() {
  607. return [];
  608. }
  609. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "prefabs", [_dec5], {
  610. configurable: true,
  611. enumerable: true,
  612. writable: true,
  613. initializer: function initializer() {
  614. return [];
  615. }
  616. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "create_node", [_dec6], {
  617. configurable: true,
  618. enumerable: true,
  619. writable: true,
  620. initializer: function initializer() {
  621. return null;
  622. }
  623. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "nodes", [_dec7], {
  624. configurable: true,
  625. enumerable: true,
  626. writable: true,
  627. initializer: function initializer() {
  628. return [];
  629. }
  630. })), _class2)) || _class));
  631. _cclegacy._RF.pop();
  632. _crd = false;
  633. }
  634. };
  635. });
  636. //# sourceMappingURL=90cb08bdd2589bd4780881bf755dafe0306918a1.js.map