789715a9ff1e6669695bc6f37f849347673e7936.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, find, instantiate, Size, UITransform, Vec2, Vec3, UI_Idiom, Layout_Idioms, GameUILayers, ui_base, ModuleDef, Container_Manager, _dec, _class, _crd, ccclass, property, UI_Idioms;
  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 _reportPossibleCrUseOfUI_Idiom(extras) {
  7. _reporterNs.report("UI_Idiom", "./UI_Idiom", _context.meta, extras);
  8. }
  9. function _reportPossibleCrUseOfLayout_Idioms(extras) {
  10. _reporterNs.report("Layout_Idioms", "./Layout_Idioms", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfGameUILayers(extras) {
  13. _reporterNs.report("GameUILayers", "../../../core/ui/ui", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfui_base(extras) {
  16. _reporterNs.report("ui_base", "../../../core/ui/ui_base", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfModuleDef(extras) {
  19. _reporterNs.report("ModuleDef", "../../../Scripts/ModuleDef", _context.meta, extras);
  20. }
  21. function _reportPossibleCrUseOfContainer_Manager(extras) {
  22. _reporterNs.report("Container_Manager", "../../game/Container_Manager", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfCube_Infor(extras) {
  25. _reporterNs.report("Cube_Infor", "../../game/Cube_Infor", _context.meta, extras);
  26. }
  27. return {
  28. setters: [function (_unresolved_) {
  29. _reporterNs = _unresolved_;
  30. }, function (_cc) {
  31. _cclegacy = _cc.cclegacy;
  32. __checkObsolete__ = _cc.__checkObsolete__;
  33. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  34. _decorator = _cc._decorator;
  35. find = _cc.find;
  36. instantiate = _cc.instantiate;
  37. Size = _cc.Size;
  38. UITransform = _cc.UITransform;
  39. Vec2 = _cc.Vec2;
  40. Vec3 = _cc.Vec3;
  41. }, function (_unresolved_2) {
  42. UI_Idiom = _unresolved_2.UI_Idiom;
  43. }, function (_unresolved_3) {
  44. Layout_Idioms = _unresolved_3.Layout_Idioms;
  45. }, function (_unresolved_4) {
  46. GameUILayers = _unresolved_4.GameUILayers;
  47. }, function (_unresolved_5) {
  48. ui_base = _unresolved_5.default;
  49. }, function (_unresolved_6) {
  50. ModuleDef = _unresolved_6.ModuleDef;
  51. }, function (_unresolved_7) {
  52. Container_Manager = _unresolved_7.Container_Manager;
  53. }],
  54. execute: function () {
  55. _crd = true;
  56. _cclegacy._RF.push({}, "efc87WIo/pPjbu6aYJ5woDB", "UI_Idioms", undefined);
  57. __checkObsolete__(['_decorator', 'Component', 'DynamicAtlasManager', 'find', 'instantiate', 'Label', 'macro', 'Node', 'Prefab', 'ScrollView', 'Size', 'UITransform', 'Vec2', 'Vec3']);
  58. ({
  59. ccclass,
  60. property
  61. } = _decorator);
  62. _export("UI_Idioms", UI_Idioms = (_dec = ccclass('UI_Idioms'), _dec(_class = class UI_Idioms extends (_crd && ui_base === void 0 ? (_reportPossibleCrUseOfui_base({
  63. error: Error()
  64. }), ui_base) : ui_base) {
  65. constructor() {
  66. super((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({
  67. error: Error()
  68. }), ModuleDef) : ModuleDef).GAME, 'ui/UI_Idioms/ScrollView', (_crd && GameUILayers === void 0 ? (_reportPossibleCrUseOfGameUILayers({
  69. error: Error()
  70. }), GameUILayers) : GameUILayers).HUD, _crd && Layout_Idioms === void 0 ? (_reportPossibleCrUseOfLayout_Idioms({
  71. error: Error()
  72. }), Layout_Idioms) : Layout_Idioms);
  73. this.idioms = [];
  74. }
  75. onCreated() {
  76. var _this = this;
  77. return _asyncToGenerator(function* () {
  78. var layout = _this.getLayout();
  79. layout.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  80. error: Error()
  81. }), Container_Manager) : Container_Manager);
  82. _this.init();
  83. })();
  84. }
  85. init() {
  86. var layout = this.getLayout();
  87. console.log("init");
  88. for (var i = 0; i < this.idioms.length; i++) {
  89. this.idioms[i].node.destroy();
  90. }
  91. this.idioms = [];
  92. for (var _i = 0; _i < layout.Container.idioms.length; _i++) {
  93. var node = instantiate(layout.idiom_prefab);
  94. node.parent = layout.content;
  95. console.log("label" + layout.Container.idioms[_i].idiom);
  96. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  97. error: Error()
  98. }), UI_Idiom) : UI_Idiom).txt.string = layout.Container.idioms[_i].idiom;
  99. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  100. error: Error()
  101. }), UI_Idiom) : UI_Idiom).piece_1_word = layout.Container.idioms[_i].piece_1_word;
  102. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  103. error: Error()
  104. }), UI_Idiom) : UI_Idiom).piece_2_word = layout.Container.idioms[_i].piece_2_word;
  105. this.idioms.push(node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  106. error: Error()
  107. }), UI_Idiom) : UI_Idiom));
  108. }
  109. layout.scrollView.scrollToTop();
  110. } //高亮显示
  111. light_Show(cube_infor) {
  112. var layout = this.getLayout();
  113. var txt_length = cube_infor.Text.length;
  114. var flag = false;
  115. for (var i = 0; i < this.idioms.length; i++) {
  116. if (this.idioms[i].piece_1_word === cube_infor.Text) {
  117. this.idioms[i].hud_sp.node.active = true;
  118. this.idioms[i].hud_sp.node.getComponent(UITransform).contentSize = new Size(30 * txt_length, 30);
  119. var target = 0;
  120. this.idioms[i].hud_sp.node.position = new Vec3(11 + target * 30, -11.5, 0);
  121. this.scrollToTarget(i);
  122. } else if (this.idioms[i].piece_2_word === cube_infor.Text) {
  123. this.idioms[i].hud_sp.node.active = true;
  124. this.idioms[i].hud_sp.node.getComponent(UITransform).contentSize = new Size(30 * txt_length, 30);
  125. var _target = 4 - txt_length;
  126. this.idioms[i].hud_sp.node.position = new Vec3(11 + _target * 30, -11.5, 0);
  127. this.scrollToTarget(i);
  128. }
  129. }
  130. } //取消高亮
  131. light_Hide(cube1, cube2) {
  132. var layout = this.getLayout();
  133. console.log("开始执行light——hide");
  134. var checkAndRemoveHint = (cube, piece_1, piece_2) => {
  135. console.log("检测并移除");
  136. var hasMatch = false; // 检查 cube 是否与成语的某个词匹配
  137. if (cube.Text === piece_1 || cube.Text === piece_2) {
  138. for (var cubeInfor of layout.Container.idiom_combine.keys()) {
  139. if (cubeInfor.txt.string === cube.Text) {
  140. hasMatch = true;
  141. break;
  142. }
  143. } // 如果当前字没有参与成语,则移除提示
  144. if (!hasMatch) {
  145. console.log("移除提示");
  146. return false;
  147. }
  148. }
  149. return true;
  150. }; // 过滤掉已匹配的成语,并销毁提示
  151. this.idioms = this.idioms.filter(element => {
  152. var shouldRemove = false; // 检查与 cube1 和 cube2 相关的成语
  153. var cube1Active = checkAndRemoveHint(cube1, element.piece_1_word, element.piece_2_word);
  154. var cube2Active = checkAndRemoveHint(cube2, element.piece_2_word, element.piece_1_word);
  155. if (!cube1Active || !cube2Active) {
  156. element.hud_sp.node.active = false; // 销毁提示
  157. } // 如果 cube1 和 cube2 组合成一个成语,销毁该成语节点
  158. if (cube1.Text + cube2.Text === element.txt.string) {
  159. element.node.destroy();
  160. shouldRemove = true;
  161. }
  162. return !shouldRemove;
  163. }); // 监测每个字是否仍然在某个成语中,如果是,则高亮显示
  164. var str = [...layout.Container.idiom_combine.keys()];
  165. var _loop = function _loop(element) {
  166. if (str.some(cubeInfor => cubeInfor.Text == element.piece_1_word || cubeInfor.Text == element.piece_2_word)) {
  167. element.hud_sp.node.active = true;
  168. } else {
  169. element.hud_sp.node.active = false;
  170. }
  171. };
  172. for (var element of this.idioms) {
  173. _loop(element);
  174. }
  175. }
  176. scrollToTarget(index) {
  177. var layout = this.getLayout();
  178. var row = Math.trunc(index / 5);
  179. if (row == 0) {
  180. layout.scrollView.scrollTo(new Vec2(0, 1), 0.2, false);
  181. } else if (row == this.idioms.length / 5) {
  182. layout.scrollView.scrollTo(new Vec2(0, 0), 0.2, false);
  183. } else {
  184. var res = Math.trunc(row / (Math.trunc(this.idioms.length / 5) - 2) * 10) / 10;
  185. layout.scrollView.scrollTo(new Vec2(0, 1 - res), 0.2, false);
  186. console.log("weizhi:" + (1 - res));
  187. }
  188. }
  189. all_light_Hide() {
  190. this.idioms.forEach(element => {
  191. element.hud_sp.node.active = false;
  192. });
  193. }
  194. }) || _class));
  195. _cclegacy._RF.pop();
  196. _crd = false;
  197. }
  198. };
  199. });
  200. //# sourceMappingURL=789715a9ff1e6669695bc6f37f849347673e7936.js.map