From aab38e323372fc059bcff4b8b4c00423ee76881e Mon Sep 17 00:00:00 2001 From: walkpan Date: Fri, 24 Apr 2026 22:13:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8B=B1=E9=9B=84=E5=8D=A1=E7=89=8CUI?= =?UTF-8?q?=E5=B9=B6=E6=94=AF=E6=8C=81=E7=AD=89=E7=BA=A7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整英雄卡牌预制体的尺寸、缩放和位置 - 在英雄信息面板中添加等级节点显示 - 修改英雄属性显示逻辑,根据英雄等级计算属性值 - 移除冗余的技能信息更新代码,简化逻辑结构 --- assets/resources/gui/element/heros.prefab | 23 +++--- assets/script/game/map/HlistComp.ts | 94 ++++++++--------------- 2 files changed, 45 insertions(+), 72 deletions(-) diff --git a/assets/resources/gui/element/heros.prefab b/assets/resources/gui/element/heros.prefab index daf16ce6..8fd481e3 100644 --- a/assets/resources/gui/element/heros.prefab +++ b/assets/resources/gui/element/heros.prefab @@ -3587,8 +3587,8 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, + "x": 1.5, + "y": 1.5, "z": 1 }, "_mobility": 0, @@ -4024,8 +4024,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 320, - "height": 450 + "width": 213.33333333333334, + "height": 300 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -4983,8 +4983,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 320, - "height": 450 + "width": 213.33333333333334, + "height": 300 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -9804,8 +9804,8 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": 145.307, - "y": -205.5, + "x": 135.807, + "y": -202.5, "z": 0 }, "_lrot": { @@ -10459,8 +10459,8 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": -141.951, - "y": -205.5, + "x": -132.451, + "y": -202.5, "z": 0 }, "_lrot": { @@ -12118,6 +12118,9 @@ "next_btn": { "__id__": 489 }, + "lv_node": { + "__id__": 266 + }, "_id": "" }, { diff --git a/assets/script/game/map/HlistComp.ts b/assets/script/game/map/HlistComp.ts index 57cf42f2..ff2ac3c7 100644 --- a/assets/script/game/map/HlistComp.ts +++ b/assets/script/game/map/HlistComp.ts @@ -18,7 +18,7 @@ * - HeroInfo / HeroList(heroSet)—— 英雄静态配置与全量英雄 UUID 列表 * - SkillSet / IType(SkillSet)—— 技能配置与类型枚举 */ -import { _decorator, Animation, AnimationClip, Button, Event, Label, Node, NodeEventType, Sprite, resources, tween, Vec3 } from "cc"; +import { _decorator, Animation, AnimationClip, Button, Event, Label, Node, NodeEventType, Sprite, resources, tween, Vec3, Widget } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { HeroInfo, HeroList } from "../common/config/heroSet"; @@ -218,10 +218,37 @@ export class HListComp extends CCComp { const hero = HeroInfo[this.huuid]; if (!hero) return; - this.setLabelText(this.name_node, hero.name); - this.setLabelText(this.ap_node, `${hero.ap}`); - this.setLabelText(this.hp_node, `${hero.hp}`); - this.updateSkillInfo(hero); + const heroLv = Math.max(1, Math.floor(hero.lv ?? 1)); + const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : ""; + this.setLabelText(this.name_node, `${suffix}${hero.name || ""}${suffix}`); + + this.setLabelText(this.ap_node, `${(hero.ap ?? 0) * heroLv}`); + this.setLabelText(this.hp_node, `${(hero.hp ?? 0) * heroLv}`); + + if (this.info_node) { + const infoLabel = this.info_node.getChildByName("info")?.getComponent(Label); + if (infoLabel) infoLabel.string = `${hero.info || ""}`; + } + + const cardLvStr = `lv${hero.cards_lv ?? 1}`; + if (this.lv_node) { + this.lv_node.active = true; + this.lv_node.children.forEach(child => { + if (child.name === "light") { + child.active = false; + } else if (child.name === "bg") { + child.active = true; + } else { + child.active = (child.name === cardLvStr); + } + }); + const widget = this.lv_node.getComponent(Widget); + if (widget) widget.updateAlignment(); + this.lv_node.children.forEach(child => { + const childWidget = child.getComponent(Widget); + if (childWidget) childWidget.updateAlignment(); + }); + } } /** 初始化 5 个轮播位的英雄动画 */ @@ -315,64 +342,7 @@ export class HListComp extends CCComp { return null; } - // ======================== 技能信息 ======================== - /** - * 更新技能信息面板: - * 遍历英雄的技能列表,为 Line1~Line5 节点填充技能名、等级、CD、描述。 - * 同时根据技能类型(近战 / 远程 / 辅助)切换对应图标。 - * - * @param hero 英雄配置数据(含 skills 字段) - */ - private updateSkillInfo(hero: any) { - if (!this.info_node) return; - - const skills = Object.values(hero.skills || {}); - - for (let i = 1; i <= 5; i++) { - let line = this.findNodeByName(this.info_node, `Line${i}`) || this.findNodeByName(this.info_node, `line${i}`); - if (!line) continue; - - const skill: any = skills[i - 1]; - if (skill) { - line.active = true; - const skillId = skill.uuid; - const config = SkillSet[skillId]; - - // 拼接技能信息文本 - const text = config ? `${config.name} Lv.${skill.lv} CD:${skill.cd}s ${config.info}` : `未知技能 CD:${skill.cd}s`; - - const noteNode = this.findNodeByName(line, "note"); - const label = noteNode?.getComponent(Label) || noteNode?.getComponentInChildren(Label) || line.getComponentInChildren(Label); - if (label) { - label.string = text; - } - - // 切换技能类型图标 - this.updateLineTypeIcon(line, config?.IType); - } else { - line.active = false; - } - } - } - - /** - * 更新技能行的类型图标(互斥显示): - * - Melee → 近战图标 - * - remote → 远程图标 - * - support → 辅助图标 - * - * @param line 技能行节点 - * @param iType 技能类型枚举 - */ - private updateLineTypeIcon(line: Node, iType?: IType) { - const meleeNode = this.findNodeByName(line, "Melee"); - const remoteNode = this.findNodeByName(line, "remote"); - const supportNode = this.findNodeByName(line, "support"); - if (meleeNode) meleeNode.active = iType === IType.Melee; - if (remoteNode) remoteNode.active = iType === IType.remote; - if (supportNode) supportNode.active = iType === IType.support; - } /** ECS 组件移除时销毁节点 */ reset() {