789715a9ff1e6669695bc6f37f849347673e7936.js 9.2 KB

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