90cb08bdd2589bd4780881bf755dafe0306918a1.js 41 KB

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