8d8e10cc93cdaf5d8a87ce905d2e79308f6c8894.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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, instantiate, Size, UITransform, Vec2, Vec3, Container_Manager, UI_Idiom, ui_base, ModuleDef, GameUILayers, Layout_Idioms, _dec, _class, _crd, ccclass, property, UI_Idioms;
  4. function _reportPossibleCrUseOfContainer_Manager(extras) {
  5. _reporterNs.report("Container_Manager", "db://assets/Scripts/Container_Manager", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfUI_Idiom(extras) {
  8. _reporterNs.report("UI_Idiom", "./UI_Idiom", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfCube_Infor(extras) {
  11. _reporterNs.report("Cube_Infor", "db://assets/Scripts/Cube_Infor", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfui_base(extras) {
  14. _reporterNs.report("ui_base", "db://assets/core/ui/ui_base", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfModuleDef(extras) {
  17. _reporterNs.report("ModuleDef", "db://assets/Scripts/ModuleDef", _context.meta, extras);
  18. }
  19. function _reportPossibleCrUseOfGameUILayers(extras) {
  20. _reporterNs.report("GameUILayers", "db://assets/core/ui/ui", _context.meta, extras);
  21. }
  22. function _reportPossibleCrUseOfLayout_Idioms(extras) {
  23. _reporterNs.report("Layout_Idioms", "./Layout_Idioms", _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. instantiate = _cc.instantiate;
  34. Size = _cc.Size;
  35. UITransform = _cc.UITransform;
  36. Vec2 = _cc.Vec2;
  37. Vec3 = _cc.Vec3;
  38. }, function (_unresolved_2) {
  39. Container_Manager = _unresolved_2.Container_Manager;
  40. }, function (_unresolved_3) {
  41. UI_Idiom = _unresolved_3.UI_Idiom;
  42. }, function (_unresolved_4) {
  43. ui_base = _unresolved_4.default;
  44. }, function (_unresolved_5) {
  45. ModuleDef = _unresolved_5.ModuleDef;
  46. }, function (_unresolved_6) {
  47. GameUILayers = _unresolved_6.GameUILayers;
  48. }, function (_unresolved_7) {
  49. Layout_Idioms = _unresolved_7.Layout_Idioms;
  50. }],
  51. execute: function () {
  52. _crd = true;
  53. _cclegacy._RF.push({}, "efc87WIo/pPjbu6aYJ5woDB", "UI_Idioms", undefined);
  54. __checkObsolete__(['_decorator', 'Component', 'DynamicAtlasManager', 'instantiate', 'Label', 'macro', 'Node', 'Prefab', 'ScrollView', 'Size', 'UITransform', 'Vec2', 'Vec3']);
  55. ({
  56. ccclass,
  57. property
  58. } = _decorator);
  59. _export("UI_Idioms", UI_Idioms = (_dec = ccclass('UI_Idioms'), _dec(_class = class UI_Idioms extends (_crd && ui_base === void 0 ? (_reportPossibleCrUseOfui_base({
  60. error: Error()
  61. }), ui_base) : ui_base) {
  62. constructor() {
  63. super((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({
  64. error: Error()
  65. }), ModuleDef) : ModuleDef).GAME, 'ui/UI_Idioms/ScrollView', (_crd && GameUILayers === void 0 ? (_reportPossibleCrUseOfGameUILayers({
  66. error: Error()
  67. }), GameUILayers) : GameUILayers).HUD, _crd && Layout_Idioms === void 0 ? (_reportPossibleCrUseOfLayout_Idioms({
  68. error: Error()
  69. }), Layout_Idioms) : Layout_Idioms);
  70. this.count = 5;
  71. this.idioms = [];
  72. }
  73. async onCreated() {
  74. this.init();
  75. }
  76. init() {
  77. const layout = this.getLayout();
  78. console.log("init");
  79. for (let i = 0; i < this.count; i++) {
  80. let node = instantiate(layout.idiom_prefab);
  81. node.parent = layout.content;
  82. console.log("label" + (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  83. error: Error()
  84. }), Container_Manager) : Container_Manager).instance.idioms[i].idiom);
  85. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  86. error: Error()
  87. }), UI_Idiom) : UI_Idiom).txt.string = (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  88. error: Error()
  89. }), Container_Manager) : Container_Manager).instance.idioms[i].idiom;
  90. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  91. error: Error()
  92. }), UI_Idiom) : UI_Idiom).piece_1_word = (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  93. error: Error()
  94. }), Container_Manager) : Container_Manager).instance.idioms[i].piece_1_word;
  95. node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({
  96. error: Error()
  97. }), UI_Idiom) : UI_Idiom).piece_2_word = (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  98. error: Error()
  99. }), Container_Manager) : Container_Manager).instance.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. } //高亮显示
  105. light_Show(cube_infor) {
  106. const layout = this.getLayout();
  107. let txt_length = cube_infor.Text.length;
  108. this.idioms.forEach(element => {
  109. if (element.piece_1_word === cube_infor.Text) {
  110. element.hud_sp.node.active = true;
  111. element.hud_sp.node.getComponent(UITransform).contentSize = new Size(20 * txt_length, 20);
  112. let target = 0;
  113. element.hud_sp.node.position = new Vec3(31 + target * 20, -16, 0);
  114. let pos = new Vec2(element.node.position.x, element.node.position.y);
  115. this.scrollToTarget(pos);
  116. } else if (element.piece_2_word === cube_infor.Text) {
  117. element.hud_sp.node.active = true;
  118. element.hud_sp.node.getComponent(UITransform).contentSize = new Size(20 * txt_length, 20);
  119. let target = 4 - txt_length;
  120. element.hud_sp.node.position = new Vec3(31 + target * 20, -16, 0);
  121. let pos = new Vec2(element.node.position.x, element.node.position.y);
  122. this.scrollToTarget(pos);
  123. }
  124. });
  125. } //取消高亮
  126. light_Hide(cube1, cube2) {
  127. const layout = this.getLayout();
  128. this.idioms = this.idioms.filter(element => {
  129. let shouldRemove = false;
  130. let hasMatch = false; // 检查与 cube1 相关的成语
  131. if (cube1.Text === element.piece_1_word) {
  132. for (const cubeInfor of (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  133. error: Error()
  134. }), Container_Manager) : Container_Manager).instance.idiom_combine.keys()) {
  135. if (cubeInfor.txt.string === cube1.Text) {
  136. hasMatch = true;
  137. break;
  138. }
  139. } // 只有当前字没有参与成语时才移除提示
  140. if (!hasMatch) {
  141. element.hud_sp.node.active = false; // 销毁UI中的成语提示
  142. }
  143. } // 检查与 cube2 相关的成语
  144. if (cube2.Text === element.piece_2_word) {
  145. for (const cubeInfor of (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  146. error: Error()
  147. }), Container_Manager) : Container_Manager).instance.idiom_combine.keys()) {
  148. if (cubeInfor.txt.string === cube2.Text) {
  149. hasMatch = true;
  150. break;
  151. }
  152. } // 只有当前字没有参与成语时才移除提示
  153. if (!hasMatch) {
  154. element.hud_sp.node.active = false; // 销毁UI中的成语提示
  155. }
  156. } // 检查是否能组合成一个成语
  157. if (cube1.Text + cube2.Text === element.txt.string) {
  158. element.node.destroy(); // 销毁节点
  159. shouldRemove = true; // 如果已组合,移除该成语
  160. } // 保留未被组合的元素
  161. return !shouldRemove;
  162. }); // 监测所有字是否仍然需要高亮显示
  163. this.idioms.forEach(element => {
  164. // 检查每个字是否仍然在任何成语组合中
  165. let shouldDisplay = false; // 遍历容器中的所有成语组合,看看当前字是否仍然参与任何组合
  166. for (const cubeInfor of (_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({
  167. error: Error()
  168. }), Container_Manager) : Container_Manager).instance.idiom_combine.keys()) {
  169. if (cubeInfor.txt.string === element.piece_1_word || cubeInfor.txt.string === element.piece_2_word) {
  170. shouldDisplay = true;
  171. break;
  172. }
  173. } // 如果该字还参与成语,则保持其提示显示
  174. if (shouldDisplay) {
  175. element.hud_sp.node.active = true;
  176. }
  177. });
  178. }
  179. scrollToTarget(pos) {
  180. const layout = this.getLayout();
  181. layout.scrollView.scrollTo(pos, 0.2, true);
  182. }
  183. all_light_Hide() {
  184. this.idioms.forEach(element => {
  185. element.hud_sp.node.active = false;
  186. });
  187. }
  188. }) || _class));
  189. _cclegacy._RF.pop();
  190. _crd = false;
  191. }
  192. };
  193. });
  194. //# sourceMappingURL=8d8e10cc93cdaf5d8a87ce905d2e79308f6c8894.js.map