6158a2d0f390f8a87809ca16670d8e228a227fb2.js 31 KB

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