67f356369ce567fe1898b7ae72038ee83758a446.js 30 KB

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