From 4fee02d82e719034a38c273df28282d37fa4451a Mon Sep 17 00:00:00 2001 From: panFD Date: Thu, 13 Aug 2026 23:16:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(hero):=20=E7=A7=BB=E9=99=A4=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E7=AD=89=E7=BA=A7=E6=98=BE=E7=A4=BA=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 从HeroTopBarComp中移除等级Label组件、lvShow方法以及等级显示调用 2. 从HeroViewComp的update逻辑中移除等级脏数据监听 3. 调整英雄顶栏预制体的布局参数并隐藏等级节点 --- assets/resources/game/heros/top.prefab | 33 +++++++++++------------ assets/script/game/hero/HeroTopBarComp.ts | 15 ++--------- assets/script/game/hero/HeroViewComp.ts | 5 ---- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/assets/resources/game/heros/top.prefab b/assets/resources/game/heros/top.prefab index a7e237a4..961d4eac 100644 --- a/assets/resources/game/heros/top.prefab +++ b/assets/resources/game/heros/top.prefab @@ -98,7 +98,7 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": 9.114, + "x": 0, "y": 10, "z": 0 }, @@ -220,7 +220,7 @@ "__id__": 17 } ], - "_active": false, + "_active": true, "_components": [ { "__id__": 25 @@ -238,7 +238,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": -9.738, + "y": -7.84, "z": 0 }, "_lrot": { @@ -290,7 +290,7 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": -35, + "x": -20, "y": 0, "z": 0 }, @@ -331,8 +331,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 70, - "height": 10 + "width": 40, + "height": 5 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -509,8 +509,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 240, - "height": 40 + "width": 140, + "height": 23.333333333333336 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -634,8 +634,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 70, - "height": 10 + "width": 40, + "height": 5 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -862,7 +862,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 40, - "height": 11 + "height": 9 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -1040,7 +1040,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 140, - "height": 43.333333333333336 + "height": 36.66666666666667 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -1165,7 +1165,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 40, - "height": 11 + "height": 9 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -1392,7 +1392,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 40, - "height": 11 + "height": 9 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -1695,7 +1695,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 40, - "height": 11 + "height": 9 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2541,7 +2541,6 @@ "__type__": "c4181/FEWhKbY0D0PLdCyKi", "_name": "", "_objFlags": 0, - "__editorExtras__": {}, "node": { "__id__": 1 }, @@ -2559,7 +2558,7 @@ "hpBarSprite": { "__id__": 36 }, - "_id": "" + "_id": "a77QVRkP5NX4b+LyqmW1KJ" }, { "__type__": "cc.CompPrefabInfo", diff --git a/assets/script/game/hero/HeroTopBarComp.ts b/assets/script/game/hero/HeroTopBarComp.ts index 04c2b421..25e51741 100644 --- a/assets/script/game/hero/HeroTopBarComp.ts +++ b/assets/script/game/hero/HeroTopBarComp.ts @@ -1,4 +1,4 @@ -import { _decorator, Label, ProgressBar, Sprite, UIOpacity, Vec3, v3, tween, Tween, Color, clamp } from "cc"; +import { _decorator, ProgressBar, Sprite, UIOpacity, Vec3, v3, tween, Tween, Color, clamp } 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 { HeroAttrsComp } from "./HeroAttrsComp"; @@ -12,7 +12,6 @@ const { ccclass, property } = _decorator; * 挂载在英雄节点下的 "top" 子节点上,独立管理: * - 血条进度(ProgressBar) * - 护盾数值条(ProgressBar,top/shield 节点,显示 shield / SHIELD_MAX) - * - 等级数字(Label) * - 透明度激活 / 闲置 * - 受击抖动动画 * @@ -27,9 +26,6 @@ export class HeroTopBarComp extends CCComp { @property({ type: ProgressBar, tooltip: "血条进度条" }) private hpProgressBar: ProgressBar = null!; - @property({ type: Label, tooltip: "等级数字" }) - private lvLabel: Label = null!; - @property({ type: ProgressBar, tooltip: "护盾数值条(top 下的 shield 节点)" }) private shieldProgressBar: ProgressBar = null!; @@ -88,12 +84,11 @@ export class HeroTopBarComp extends CCComp { // 重置显示状态 this.node.getChildByName("hp")!.active = true; this.node.getChildByName("cd")!.active = false; - this.node.getChildByName("lv")!.active = true; + this.node.getChildByName("lv")!.active = false; this.node.active = true; this.setTopBarOpacity(false); this.hpShow(); - this.lvShow(); this.shieldShow(model.shield); } @@ -125,12 +120,6 @@ export class HeroTopBarComp extends CCComp { this.shieldProgressBar.node.active = shield > 0; } - /** 更新等级数字 */ - public lvShow(): void { - if (!this.lvLabel || !this._model) return; - this.lvLabel.string = String(this._model.lv); - } - /** 激活顶栏(高亮 + 延迟恢复闲置透明度) */ public activateTopBar(): void { this.setTopBarOpacity(true); diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index b044550a..057bdcb8 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -139,11 +139,6 @@ export class HeroViewComp extends CCComp { this.topBar.shieldShow(this.model.shield); this.model.dirty_shield = false; } - - if (this.model.dirty_lv) { - this.topBar.lvShow(); - this.model.dirty_lv = false; - } } public cd_show() {