System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6"], function (_export, _context) { "use strict"; 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; function _reportPossibleCrUseOfUI_Idiom(extras) { _reporterNs.report("UI_Idiom", "./UI_Idiom", _context.meta, extras); } function _reportPossibleCrUseOfLayout_Idioms(extras) { _reporterNs.report("Layout_Idioms", "./Layout_Idioms", _context.meta, extras); } function _reportPossibleCrUseOfGameUILayers(extras) { _reporterNs.report("GameUILayers", "../../../core/ui/ui", _context.meta, extras); } function _reportPossibleCrUseOfui_base(extras) { _reporterNs.report("ui_base", "../../../core/ui/ui_base", _context.meta, extras); } function _reportPossibleCrUseOfModuleDef(extras) { _reporterNs.report("ModuleDef", "../../../Scripts/ModuleDef", _context.meta, extras); } function _reportPossibleCrUseOfContainer_Manager(extras) { _reporterNs.report("Container_Manager", "../../game/Container_Manager", _context.meta, extras); } function _reportPossibleCrUseOfCube_Infor(extras) { _reporterNs.report("Cube_Infor", "../../game/Cube_Infor", _context.meta, extras); } return { setters: [function (_unresolved_) { _reporterNs = _unresolved_; }, function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; _decorator = _cc._decorator; find = _cc.find; instantiate = _cc.instantiate; Size = _cc.Size; UITransform = _cc.UITransform; Vec2 = _cc.Vec2; Vec3 = _cc.Vec3; }, function (_unresolved_2) { UI_Idiom = _unresolved_2.UI_Idiom; }, function (_unresolved_3) { Layout_Idioms = _unresolved_3.Layout_Idioms; }, function (_unresolved_4) { GameUILayers = _unresolved_4.GameUILayers; }, function (_unresolved_5) { ui_base = _unresolved_5.default; }, function (_unresolved_6) { ModuleDef = _unresolved_6.ModuleDef; }, function (_unresolved_7) { Container_Manager = _unresolved_7.Container_Manager; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "efc87WIo/pPjbu6aYJ5woDB", "UI_Idioms", undefined); __checkObsolete__(['_decorator', 'Component', 'DynamicAtlasManager', 'find', 'instantiate', 'Label', 'macro', 'Node', 'Prefab', 'ScrollView', 'Size', 'UITransform', 'Vec2', 'Vec3']); ({ ccclass, property } = _decorator); _export("UI_Idioms", UI_Idioms = (_dec = ccclass('UI_Idioms'), _dec(_class = class UI_Idioms extends (_crd && ui_base === void 0 ? (_reportPossibleCrUseOfui_base({ error: Error() }), ui_base) : ui_base) { constructor() { super((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({ error: Error() }), ModuleDef) : ModuleDef).GAME, 'ui/UI_Idioms/ScrollView', (_crd && GameUILayers === void 0 ? (_reportPossibleCrUseOfGameUILayers({ error: Error() }), GameUILayers) : GameUILayers).HUD, _crd && Layout_Idioms === void 0 ? (_reportPossibleCrUseOfLayout_Idioms({ error: Error() }), Layout_Idioms) : Layout_Idioms); this.idioms = []; } async onCreated() { const layout = this.getLayout(); layout.Container = find('Container').getComponent(_crd && Container_Manager === void 0 ? (_reportPossibleCrUseOfContainer_Manager({ error: Error() }), Container_Manager) : Container_Manager); this.init(); } init() { const layout = this.getLayout(); console.log("init"); for (let i = 0; i < this.idioms.length; i++) { this.idioms[i].node.destroy(); } this.idioms = []; for (let i = 0; i < layout.Container.idioms.length; i++) { let node = instantiate(layout.idiom_prefab); node.parent = layout.content; console.log("label" + layout.Container.idioms[i].idiom); node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({ error: Error() }), UI_Idiom) : UI_Idiom).txt.string = layout.Container.idioms[i].idiom; node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({ error: Error() }), UI_Idiom) : UI_Idiom).piece_1_word = layout.Container.idioms[i].piece_1_word; node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({ error: Error() }), UI_Idiom) : UI_Idiom).piece_2_word = layout.Container.idioms[i].piece_2_word; this.idioms.push(node.getComponent(_crd && UI_Idiom === void 0 ? (_reportPossibleCrUseOfUI_Idiom({ error: Error() }), UI_Idiom) : UI_Idiom)); } layout.scrollView.scrollToTop(); } //高亮显示 light_Show(cube_infor) { const layout = this.getLayout(); let txt_length = cube_infor.Text.length; let flag = false; for (let i = 0; i < this.idioms.length; i++) { if (this.idioms[i].piece_1_word === cube_infor.Text) { this.idioms[i].hud_sp.node.active = true; this.idioms[i].hud_sp.node.getComponent(UITransform).contentSize = new Size(30 * txt_length, 30); let target = 0; this.idioms[i].hud_sp.node.position = new Vec3(11 + target * 30, -11.5, 0); this.scrollToTarget(i); } else if (this.idioms[i].piece_2_word === cube_infor.Text) { this.idioms[i].hud_sp.node.active = true; this.idioms[i].hud_sp.node.getComponent(UITransform).contentSize = new Size(30 * txt_length, 30); let target = 4 - txt_length; this.idioms[i].hud_sp.node.position = new Vec3(11 + target * 30, -11.5, 0); this.scrollToTarget(i); } } } //取消高亮 light_Hide(cube1, cube2) { const layout = this.getLayout(); console.log("开始执行light——hide"); const checkAndRemoveHint = (cube, piece_1, piece_2) => { console.log("检测并移除"); let hasMatch = false; // 检查 cube 是否与成语的某个词匹配 if (cube.Text === piece_1 || cube.Text === piece_2) { for (const cubeInfor of layout.Container.idiom_combine.keys()) { if (cubeInfor.txt.string === cube.Text) { hasMatch = true; break; } } // 如果当前字没有参与成语,则移除提示 if (!hasMatch) { console.log("移除提示"); return false; } } return true; }; // 过滤掉已匹配的成语,并销毁提示 this.idioms = this.idioms.filter(element => { let shouldRemove = false; // 检查与 cube1 和 cube2 相关的成语 const cube1Active = checkAndRemoveHint(cube1, element.piece_1_word, element.piece_2_word); const cube2Active = checkAndRemoveHint(cube2, element.piece_2_word, element.piece_1_word); if (!cube1Active || !cube2Active) { element.hud_sp.node.active = false; // 销毁提示 } // 如果 cube1 和 cube2 组合成一个成语,销毁该成语节点 if (cube1.Text + cube2.Text === element.txt.string) { element.node.destroy(); shouldRemove = true; } return !shouldRemove; }); // 监测每个字是否仍然在某个成语中,如果是,则高亮显示 const str = [...layout.Container.idiom_combine.keys()]; for (const element of this.idioms) { if (str.some(cubeInfor => cubeInfor.Text == element.piece_1_word || cubeInfor.Text == element.piece_2_word)) { element.hud_sp.node.active = true; } else { element.hud_sp.node.active = false; } } } scrollToTarget(index) { const layout = this.getLayout(); let row = Math.trunc(index / 5); if (row == 0) { layout.scrollView.scrollTo(new Vec2(0, 1), 0.2, false); } else if (row == this.idioms.length / 5) { layout.scrollView.scrollTo(new Vec2(0, 0), 0.2, false); } else { let res = Math.trunc(row / (Math.trunc(this.idioms.length / 5) - 2) * 10) / 10; layout.scrollView.scrollTo(new Vec2(0, 1 - res), 0.2, false); console.log("weizhi:" + (1 - res)); } } all_light_Hide() { this.idioms.forEach(element => { element.hud_sp.node.active = false; }); } }) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=789715a9ff1e6669695bc6f37f849347673e7936.js.map