67f356369ce567fe1898b7ae72038ee83758a446.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Camera, Component, find, geometry, Layers, Node, PhysicsSystem, Quat, RigidBody, sp, tween, Vec3, gui, UI_Idioms, UI_Main, Container_Manager, Cube_Infor, Cube_State, UI_LatticeFull, UI_Lock, Toast, ch_audio, Hall, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _class3, _crd, ccclass, property, GameCtl;
  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 _reportPossibleCrUseOfgui(extras) {
  10. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfUI_Idioms(extras) {
  13. _reporterNs.report("UI_Idioms", "../ui/UI_Idioms/UI_Idioms", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfUI_Main(extras) {
  16. _reporterNs.report("UI_Main", "../ui/UI_Main/UI_Main", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfContainer_Manager(extras) {
  19. _reporterNs.report("Container_Manager", "./Container_Manager", _context.meta, extras);
  20. }
  21. function _reportPossibleCrUseOfCube_Infor(extras) {
  22. _reporterNs.report("Cube_Infor", "./Cube_Infor", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfCube_State(extras) {
  25. _reporterNs.report("Cube_State", "./Cube_Infor", _context.meta, extras);
  26. }
  27. function _reportPossibleCrUseOfUI_LatticeFull(extras) {
  28. _reporterNs.report("UI_LatticeFull", "../ui/UI_LatticeFull/UI_LatticeFull", _context.meta, extras);
  29. }
  30. function _reportPossibleCrUseOfUI_Lock(extras) {
  31. _reporterNs.report("UI_Lock", "../ui/UI_Lock/UI_Lock", _context.meta, extras);
  32. }
  33. function _reportPossibleCrUseOfLayout_Main(extras) {
  34. _reporterNs.report("Layout_Main", "../ui/UI_Main/Layout_Main", _context.meta, extras);
  35. }
  36. function _reportPossibleCrUseOfToast(extras) {
  37. _reporterNs.report("Toast", "../../core/util_class/Toast", _context.meta, extras);
  38. }
  39. function _reportPossibleCrUseOfch_audio(extras) {
  40. _reporterNs.report("ch_audio", "../../ch/audio/audio", _context.meta, extras);
  41. }
  42. function _reportPossibleCrUseOfHall(extras) {
  43. _reporterNs.report("Hall", "../hall/Hall", _context.meta, extras);
  44. }
  45. return {
  46. setters: [function (_unresolved_) {
  47. _reporterNs = _unresolved_;
  48. }, function (_cc) {
  49. _cclegacy = _cc.cclegacy;
  50. __checkObsolete__ = _cc.__checkObsolete__;
  51. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  52. _decorator = _cc._decorator;
  53. Camera = _cc.Camera;
  54. Component = _cc.Component;
  55. find = _cc.find;
  56. geometry = _cc.geometry;
  57. Layers = _cc.Layers;
  58. Node = _cc.Node;
  59. PhysicsSystem = _cc.PhysicsSystem;
  60. Quat = _cc.Quat;
  61. RigidBody = _cc.RigidBody;
  62. sp = _cc.sp;
  63. tween = _cc.tween;
  64. Vec3 = _cc.Vec3;
  65. }, function (_unresolved_2) {
  66. gui = _unresolved_2.gui;
  67. }, function (_unresolved_3) {
  68. UI_Idioms = _unresolved_3.UI_Idioms;
  69. }, function (_unresolved_4) {
  70. UI_Main = _unresolved_4.UI_Main;
  71. }, function (_unresolved_5) {
  72. Container_Manager = _unresolved_5.Container_Manager;
  73. }, function (_unresolved_6) {
  74. Cube_Infor = _unresolved_6.Cube_Infor;
  75. Cube_State = _unresolved_6.Cube_State;
  76. }, function (_unresolved_7) {
  77. UI_LatticeFull = _unresolved_7.UI_LatticeFull;
  78. }, function (_unresolved_8) {
  79. UI_Lock = _unresolved_8.UI_Lock;
  80. }, function (_unresolved_9) {
  81. Toast = _unresolved_9.Toast;
  82. }, function (_unresolved_10) {
  83. ch_audio = _unresolved_10.default;
  84. }, function (_unresolved_11) {
  85. Hall = _unresolved_11.Hall;
  86. }],
  87. execute: function () {
  88. _crd = true;
  89. _cclegacy._RF.push({}, "5237f+4/ftIlKW+rC062l8C", "GameCtl", undefined);
  90. __checkObsolete__(['_decorator', 'BoxCollider', 'Camera', 'Component', 'director', 'EventTouch', 'find', 'Game', 'geometry', 'Layers', 'Layout', 'Node', 'PhysicsSystem', 'Quat', 'RigidBody', 'Size', 'sp', 'tween', 'UITransform', 'v3', 'Vec3']);
  91. ({
  92. ccclass,
  93. property
  94. } = _decorator);
  95. _export("GameCtl", GameCtl = (_dec = ccclass('GameCtl'), _dec2 = property(Camera), _dec3 = property([Node]), _dec4 = property(Node), _dec(_class = (_class2 = (_class3 = class GameCtl extends Component {
  96. constructor() {
  97. super(...arguments);
  98. _initializerDefineProperty(this, "camera", _descriptor, this);
  99. _initializerDefineProperty(this, "Ani", _descriptor2, this);
  100. _initializerDefineProperty(this, "Mid", _descriptor3, this);
  101. this.Container = void 0;
  102. }
  103. onLoad() {
  104. GameCtl.instance = this;
  105. this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
  106. this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
  107. this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  108. this.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  109. error: Error()
  110. }), Container_Manager) : Container_Manager);
  111. }
  112. update(deltaTime) {}
  113. onTouchStart(event) {}
  114. onTouchMove(event) {}
  115. onTouchEnd(event) {
  116. if (this.Container.canTouch) {
  117. this.shootRay(event);
  118. }
  119. }
  120. shootRay(event) {
  121. if (!this.camera) return;
  122. var ray = new geometry.Ray();
  123. this.camera.screenPointToRay(event.getLocationX(), event.getLocationY(), ray);
  124. if (PhysicsSystem.instance.raycast(ray)) {
  125. var results = PhysicsSystem.instance.raycastResults; // 筛选出不在 "IGNORE_RAYCAST" 层的物体
  126. var filteredResults = results.filter(e => e.collider.node.layer !== 1 << Layers.nameToLayer('IGNORE_RAYCAST')); // 根据距离排序,确保第 0 个是最近的物体
  127. filteredResults.sort((a, b) => a.distance - b.distance);
  128. console.log(filteredResults);
  129. if (filteredResults.length > 0) {
  130. var _node$getComponent;
  131. var collider = filteredResults[0].collider;
  132. var node = collider.node; // 检查物体是否可消除
  133. if (((_node$getComponent = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  134. error: Error()
  135. }), Cube_Infor) : Cube_Infor)) == null ? void 0 : _node$getComponent.state) === (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  136. error: Error()
  137. }), Cube_State) : Cube_State).live) {
  138. (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
  139. error: Error()
  140. }), ch_audio) : ch_audio).getInstance().playOneShot('sound/click_Cube');
  141. if ((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  142. error: Error()
  143. }), Hall) : Hall).getInstance().firstEnter) {
  144. if (this.Container.nodeReferences.length > 4) {
  145. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  146. error: Error()
  147. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  148. error: Error()
  149. }), UI_Main) : UI_Main).getLayout().Hands[this.Container.nodeReferences.indexOf(node)].active = false;
  150. }
  151. }
  152. this.entryContainer(node);
  153. } else if (node.name === 'Lock') {
  154. this.UnLock(node);
  155. }
  156. }
  157. }
  158. console.log('发射了射线');
  159. }
  160. entryContainer(node) {
  161. // 判断容器剩余容量
  162. var startIndex = -1;
  163. var targetPos = new Vec3();
  164. var txt_length = node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  165. error: Error()
  166. }), Cube_Infor) : Cube_Infor).Text.length;
  167. console.log(txt_length); // 判断字长 并 判断是否还有空间可放置
  168. switch (txt_length) {
  169. case 1:
  170. for (var i = 0; i < this.Container.unlock_Num; i++) {
  171. if (this.Container.node_isIdiom[i] === false) {
  172. startIndex = i; // 找到连续的三个 false,记录起始位置
  173. break; // 找到第一个符合条件的位置后停止
  174. }
  175. }
  176. if (startIndex !== -1) {
  177. // 如果找到了一个值为 false 的元素
  178. targetPos = this.Container.nodes[startIndex].getWorldPosition().clone();
  179. this.Container.node_isIdiom[startIndex] = true;
  180. console.log(targetPos);
  181. } else {
  182. (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  183. error: Error()
  184. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  185. error: Error()
  186. }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
  187. }
  188. break;
  189. case 2:
  190. {
  191. for (var _i = 0; _i < this.Container.unlock_Num - 1; _i++) {
  192. if (this.Container.node_isIdiom[_i] === false && this.Container.node_isIdiom[_i + 1] === false) {
  193. startIndex = _i; // 找到连续的两个 false,记录起始位置
  194. break; // 找到第一个符合条件的位置后停止
  195. }
  196. }
  197. if (startIndex !== -1) {
  198. console.log("找到连续的两个 false,起始索引是:", startIndex); // 可以在此使用 startIndex 进行后续操作,例如:
  199. var pos1 = this.Container.nodes[startIndex].getWorldPosition();
  200. var pos2 = this.Container.nodes[startIndex + 1].getWorldPosition();
  201. this.Container.node_isIdiom[startIndex] = true;
  202. this.Container.node_isIdiom[startIndex + 1] = true;
  203. targetPos.set((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2, (pos1.z + pos2.z) / 2);
  204. console.log(targetPos);
  205. } else {
  206. (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  207. error: Error()
  208. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  209. error: Error()
  210. }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
  211. }
  212. break;
  213. }
  214. case 3:
  215. {
  216. for (var _i2 = 0; _i2 < this.Container.unlock_Num - 2; _i2++) {
  217. if (this.Container.node_isIdiom[_i2] === false && this.Container.node_isIdiom[_i2 + 1] === false && this.Container.node_isIdiom[_i2 + 2] === false) {
  218. startIndex = _i2; // 找到连续的三个 false,记录起始位置
  219. break; // 找到第一个符合条件的位置后停止
  220. }
  221. }
  222. if (startIndex !== -1) {
  223. // 找到连续三个 false,startIndex 即为最前面的索引
  224. console.log("找到连续的三个 false,起始索引是:", startIndex); // 可以在此使用 startIndex 进行后续操作,例如:
  225. var _pos = this.Container.nodes[startIndex].getWorldPosition();
  226. var _pos2 = this.Container.nodes[startIndex + 1].getWorldPosition();
  227. var pos3 = this.Container.nodes[startIndex + 2].getWorldPosition();
  228. this.Container.node_isIdiom[startIndex] = true;
  229. this.Container.node_isIdiom[startIndex + 1] = true;
  230. this.Container.node_isIdiom[startIndex + 2] = true;
  231. targetPos.set((_pos.x + _pos2.x + pos3.x) / 3, (_pos.y + _pos2.y + pos3.y) / 3, (_pos.z + _pos2.z + pos3.z) / 3);
  232. console.log(targetPos);
  233. } else {
  234. (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  235. error: Error()
  236. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  237. error: Error()
  238. }), gui) : gui).getLayerNode(5), "剩余槽位无法放下该词块").show();
  239. }
  240. break;
  241. }
  242. default:
  243. return;
  244. }
  245. if (startIndex !== -1) {
  246. // node.getComponent(Cube_Infor).lock = true;
  247. //生成一个新方块在场上剩余方块的方块的下方
  248. this.Container.instantiateNewCube();
  249. node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  250. error: Error()
  251. }), Cube_Infor) : Cube_Infor).state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  252. error: Error()
  253. }), Cube_State) : Cube_State).wait;
  254. node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  255. error: Error()
  256. }), Cube_Infor) : Cube_Infor).rigidbody.type = RigidBody.Type.STATIC; // 禁用重力
  257. var targetRotation = new Quat();
  258. var rotationX = node.eulerAngles.x; // 由于你初始是绕 X 轴旋转了 -90度,所以判断区间可以参考这个旋转角度
  259. if (rotationX >= -180 && rotationX < 0) {
  260. Quat.fromEuler(targetRotation, -90, 0, 0);
  261. } else {
  262. Quat.fromEuler(targetRotation, 90, 0, 0);
  263. }
  264. this.Container.canTouch = false;
  265. tween(node).to(0.2, {
  266. position: new Vec3(targetPos.x, targetPos.y, targetPos.z + 0.4),
  267. rotation: targetRotation
  268. }).call(() => {
  269. this.Container.idiom_combine.set(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  270. error: Error()
  271. }), Cube_Infor) : Cube_Infor), startIndex); // 执行判断成语合成逻辑
  272. var matchedCubes = [];
  273. var flag = this.Container.checkIdiom_Combine(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  274. error: Error()
  275. }), Cube_Infor) : Cube_Infor), matchedCubes);
  276. if (flag) {
  277. // 执行合成动画
  278. console.log("匹配的成语方块:", matchedCubes);
  279. this.combine_ani(matchedCubes[0], matchedCubes[1]);
  280. } else {
  281. //高亮
  282. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  283. error: Error()
  284. }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
  285. error: Error()
  286. }), UI_Idioms) : UI_Idioms).light_Show(node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  287. error: Error()
  288. }), Cube_Infor) : Cube_Infor)); //判断槽子满了吗
  289. var count = 0;
  290. for (var element of this.Container.node_isIdiom) {
  291. if (element == true) {
  292. count++;
  293. }
  294. }
  295. if (count == this.Container.unlock_Num) {
  296. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  297. error: Error()
  298. }), gui) : gui).show(_crd && UI_LatticeFull === void 0 ? (_reportPossibleCrUseOfUI_LatticeFull({
  299. error: Error()
  300. }), UI_LatticeFull) : UI_LatticeFull);
  301. } else if (count >= this.Container.unlock_Num - 2 && this.Container.unlock_Num != 9) {
  302. if (!this.Container.is_Show_UI_Lock) {
  303. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  304. error: Error()
  305. }), gui) : gui).show(_crd && UI_Lock === void 0 ? (_reportPossibleCrUseOfUI_Lock({
  306. error: Error()
  307. }), UI_Lock) : UI_Lock);
  308. this.Container.is_Show_UI_Lock = true;
  309. }
  310. }
  311. this.Container.canTouch = true;
  312. }
  313. }).start();
  314. }
  315. } //合成动画
  316. combine_ani(cube1, cube2) {
  317. this.Container.canTouch = true;
  318. for (var i = this.Container.idiom_combine.get(cube1); i < this.Container.idiom_combine.get(cube1) + cube1.Text.length; i++) {
  319. this.Container.node_isIdiom[i] = false;
  320. }
  321. this.Container.idiom_combine.delete(cube1);
  322. for (var _i3 = this.Container.idiom_combine.get(cube2); _i3 < this.Container.idiom_combine.get(cube2) + cube2.Text.length; _i3++) {
  323. this.Container.node_isIdiom[_i3] = false;
  324. }
  325. this.Container.idiom_combine.delete(cube2); // 取消相关字的高亮显示
  326. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  327. error: Error()
  328. }), gui) : gui).get(_crd && UI_Idioms === void 0 ? (_reportPossibleCrUseOfUI_Idioms({
  329. error: Error()
  330. }), UI_Idioms) : UI_Idioms).light_Hide(cube1, cube2);
  331. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  332. error: Error()
  333. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  334. error: Error()
  335. }), UI_Main) : UI_Main).evt.emit((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  336. error: Error()
  337. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  338. error: Error()
  339. }), UI_Main) : UI_Main).evt.key.update_remain);
  340. this.adjustContainer();
  341. var index1 = 0;
  342. if (cube1.Text.length == 1) {
  343. index1 = 0;
  344. } else if (cube1.Text.length == 2) {
  345. index1 = 2;
  346. } else if (cube1.Text.length == 3) {
  347. index1 = 4;
  348. }
  349. var index2 = 0;
  350. if (cube2.Text.length == 1) {
  351. index2 = 5;
  352. } else if (cube2.Text.length == 2) {
  353. index2 = 3;
  354. } else if (cube2.Text.length == 3) {
  355. index2 = 1;
  356. } // 检测容器中哪些字需要高亮显示
  357. console.log(this.Container.node_isIdiom); // 在所有动画结束后执行
  358. this.Container.idioms = this.Container.idioms.filter(c => c.idiom !== cube1.Text + cube2.Text); // 创建第一个 tween 动画
  359. (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
  360. error: Error()
  361. }), ch_audio) : ch_audio).getInstance().playOneShot('sound/fly_Cube');
  362. var tween1 = tween(cube1.node).to(0.25, {
  363. position: new Vec3(this.Mid[0].position.x, this.Mid[0].position.y, this.Mid[0].position.z)
  364. }).call(() => {
  365. cube1.node.layer = 1 << Layers.nameToLayer('Cube2');
  366. cube1.node.walk(child => {
  367. child.layer = 1 << Layers.nameToLayer('Cube2');
  368. });
  369. this.playAnim();
  370. (_crd && ch_audio === void 0 ? (_reportPossibleCrUseOfch_audio({
  371. error: Error()
  372. }), ch_audio) : ch_audio).getInstance().playOneShot('sound/eliminate'); // this.Container.skeleton2.getComponent(sp.Skeleton).setAnimation(0, 'anim2', false);
  373. }).to(0.3, {
  374. position: new Vec3(this.Ani[index1].position.x, this.Ani[index1].position.y, this.Ani[index1].position.z + 0.4)
  375. }).call(() => {
  376. setTimeout(() => {
  377. cube1.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  378. error: Error()
  379. }), Cube_State) : Cube_State).dead;
  380. this.Container.recycleCube(cube1.node);
  381. }, 600.0);
  382. }); // 创建第二个 tween 动画
  383. var tween2 = tween(cube2.node).to(0.3, {
  384. position: new Vec3(this.Mid[1].position.x, this.Mid[1].position.y, this.Mid[1].position.z)
  385. }).call(() => {
  386. cube2.node.layer = 1 << Layers.nameToLayer('Cube2');
  387. cube2.node.walk(child => {
  388. child.layer = 1 << Layers.nameToLayer('Cube2');
  389. });
  390. }).to(0.25, {
  391. position: new Vec3(this.Ani[index2].position.x, this.Ani[index2].position.y, this.Ani[index2].position.z + 0.4)
  392. }).call(() => {
  393. setTimeout(() => {
  394. cube2.state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  395. error: Error()
  396. }), Cube_State) : Cube_State).dead;
  397. this.Container.recycleCube(cube2.node);
  398. }, 600.0);
  399. }); // 使用 tween 的并行组合功能
  400. tween(cube1.node).parallel(tween1, tween2) // 并行执行 tween1 和 tween2
  401. .call(() => {
  402. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  403. error: Error()
  404. }), Hall) : Hall).getInstance().player.set_combine_num(1);
  405. if ((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  406. error: Error()
  407. }), Hall) : Hall).getInstance().firstEnter) {
  408. if (this.Container.nodeReferences.length == 4) {
  409. this.Container.nodeReferences.forEach(node => {
  410. node.getComponent(_crd && Cube_Infor === void 0 ? (_reportPossibleCrUseOfCube_Infor({
  411. error: Error()
  412. }), Cube_Infor) : Cube_Infor).state = (_crd && Cube_State === void 0 ? (_reportPossibleCrUseOfCube_State({
  413. error: Error()
  414. }), Cube_State) : Cube_State).live;
  415. });
  416. }
  417. }
  418. }).start();
  419. }
  420. adjustContainer() {
  421. var container = this.Container; // 新的 node_isIdiom 状态数组
  422. var newNodeIsIdiom = Array(container.node_isIdiom.length).fill(false); // 新的 idiom_combine 映射表
  423. var newIdiomCombine = new Map(); // 遍历 idiom_combine,重新计算位置
  424. for (var [cube, startIndex] of container.idiom_combine.entries()) {
  425. var txtLength = cube.Text.length; // 获取字长
  426. var targetIndex = -1; // 目标位置起始索引
  427. var targetPos = new Vec3();
  428. switch (txtLength) {
  429. case 1:
  430. {
  431. // 找到一个空位
  432. for (var i = 0; i < container.unlock_Num; i++) {
  433. if (!newNodeIsIdiom[i]) {
  434. targetIndex = i;
  435. break;
  436. }
  437. }
  438. if (targetIndex !== -1) {
  439. targetPos = container.nodes[targetIndex].getWorldPosition().clone();
  440. newNodeIsIdiom[targetIndex] = true; // 占用位置
  441. }
  442. break;
  443. }
  444. case 2:
  445. {
  446. // 找到连续两个空位
  447. for (var _i4 = 0; _i4 < container.unlock_Num - 1; _i4++) {
  448. if (!newNodeIsIdiom[_i4] && !newNodeIsIdiom[_i4 + 1]) {
  449. targetIndex = _i4;
  450. break;
  451. }
  452. }
  453. if (targetIndex !== -1) {
  454. var pos1 = container.nodes[targetIndex].getWorldPosition();
  455. var pos2 = container.nodes[targetIndex + 1].getWorldPosition();
  456. targetPos.set((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2, (pos1.z + pos2.z) / 2);
  457. newNodeIsIdiom[targetIndex] = true;
  458. newNodeIsIdiom[targetIndex + 1] = true;
  459. }
  460. break;
  461. }
  462. case 3:
  463. {
  464. // 找到连续三个空位
  465. for (var _i5 = 0; _i5 < container.unlock_Num - 2; _i5++) {
  466. if (!newNodeIsIdiom[_i5] && !newNodeIsIdiom[_i5 + 1] && !newNodeIsIdiom[_i5 + 2]) {
  467. targetIndex = _i5;
  468. break;
  469. }
  470. }
  471. if (targetIndex !== -1) {
  472. var _pos3 = container.nodes[targetIndex].getWorldPosition();
  473. var _pos4 = container.nodes[targetIndex + 1].getWorldPosition();
  474. var pos3 = container.nodes[targetIndex + 2].getWorldPosition();
  475. targetPos.set((_pos3.x + _pos4.x + pos3.x) / 3, (_pos3.y + _pos4.y + pos3.y) / 3, (_pos3.z + _pos4.z + pos3.z) / 3);
  476. newNodeIsIdiom[targetIndex] = true;
  477. newNodeIsIdiom[targetIndex + 1] = true;
  478. newNodeIsIdiom[targetIndex + 2] = true;
  479. }
  480. break;
  481. }
  482. default:
  483. return;
  484. } // 移动 Cube_Infor 到目标位置
  485. if (targetIndex !== -1) {
  486. tween(cube.node).to(0.3, {
  487. position: new Vec3(targetPos.x, targetPos.y, targetPos.z + 0.4)
  488. }).start();
  489. newIdiomCombine.set(cube, targetIndex); // 更新新映射
  490. }
  491. } // 更新 container 状态
  492. container.node_isIdiom = newNodeIsIdiom;
  493. container.idiom_combine = newIdiomCombine;
  494. console.log("调整后的容器状态:", container.node_isIdiom);
  495. console.log("更新后的 idiom_combine:", [...container.idiom_combine.entries()]);
  496. }
  497. UnLock(node) {
  498. var _this = this;
  499. return _asyncToGenerator(function* () {
  500. var res = yield chsdk.playRewardAd('解锁槽位');
  501. if (res) {
  502. for (var i = 0; i < 2; i++) {
  503. if (_this.Container.Lock_node[i].active) {
  504. _this.Container.Lock_node[i].active = false;
  505. _this.Container.unlock_Num += 1;
  506. (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  507. error: Error()
  508. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  509. error: Error()
  510. }), UI_Main) : UI_Main).evt.emit((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  511. error: Error()
  512. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  513. error: Error()
  514. }), UI_Main) : UI_Main).evt.key.resume);
  515. return;
  516. }
  517. }
  518. }
  519. })();
  520. }
  521. playAnim() {
  522. var skeleton = this.Container.skeleton1.getComponent(sp.Skeleton); // 播放 anim_2, anim_3, anim_4,同时使用不同的轨道
  523. skeleton.setAnimation(0, 'anim_2', false); // 轨道 0 播放 anim_2
  524. skeleton.setAnimation(1, 'anim_3', false); // 轨道 1 播放 anim_3
  525. skeleton.setAnimation(2, 'anim_4', false); // 轨道 2 播放 anim_4
  526. // 监听所有轨道完成,最后播放 anim_1
  527. var completedTracks = new Set(); // 记录完成的轨道
  528. skeleton.setCompleteListener(trackEntry => {
  529. completedTracks.add(trackEntry.trackIndex); // 将完成的轨道加入记录
  530. console.log("\u8F68\u9053 " + trackEntry.trackIndex + " \u7684\u52A8\u753B\u5B8C\u6210"); // 如果轨道 0、1、2 都完成,则播放 anim_1
  531. if (completedTracks.has(0) && completedTracks.has(1) && completedTracks.has(2)) {
  532. console.log('所有动画完成,播放 anim_1'); // 播放 anim_1 并监听其完成事件
  533. skeleton.setAnimation(0, 'anim_1', false); // 非循环播放 anim_1
  534. skeleton.setCompleteListener(trackEntry => {
  535. if (trackEntry.animation.name === 'anim_1') {
  536. console.log('anim_1 播放完成');
  537. skeleton.setCompleteListener(null); // 移除监听器,防止重复触发
  538. }
  539. });
  540. }
  541. });
  542. }
  543. }, _class3.instance = null, _class3), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "camera", [_dec2], {
  544. configurable: true,
  545. enumerable: true,
  546. writable: true,
  547. initializer: function initializer() {
  548. return null;
  549. }
  550. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "Ani", [_dec3], {
  551. configurable: true,
  552. enumerable: true,
  553. writable: true,
  554. initializer: function initializer() {
  555. return [];
  556. }
  557. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "Mid", [_dec4], {
  558. configurable: true,
  559. enumerable: true,
  560. writable: true,
  561. initializer: function initializer() {
  562. return [];
  563. }
  564. })), _class2)) || _class));
  565. _cclegacy._RF.pop();
  566. _crd = false;
  567. }
  568. };
  569. });
  570. //# sourceMappingURL=67f356369ce567fe1898b7ae72038ee83758a446.js.map