From 42639971242056e0975311b905425c283a89839f Mon Sep 17 00:00:00 2001 From: pan Date: Tue, 1 Sep 2026 16:41:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(hero):=20=E4=BF=AE=E5=A4=8D=E5=A4=A7?= =?UTF-8?q?=E6=8B=9B=E6=92=AD=E6=94=BE=E7=BB=93=E6=9D=9F=E5=90=8E=E6=9C=AA?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=B1=82=E7=BA=A7=E7=BD=AE=E9=A1=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增isCastingMax标记跟踪大招播放状态,在释放大招时设置该标记 2. 在动画播放结束回调中,当大招动画播放完成时清除置顶标记 3. 调整渲染排序逻辑,将大招播放中的英雄置于渲染层级最下方 4. 在角色死亡和重置时同步重置置顶标记 --- assets/script/game/hero/HeroAnmComp.ts | 7 +++++++ assets/script/game/hero/HeroViewComp.ts | 6 ++++++ assets/script/game/hero/MoveComp.ts | 7 +++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/script/game/hero/HeroAnmComp.ts b/assets/script/game/hero/HeroAnmComp.ts index 802f3406..fc6ee182 100644 --- a/assets/script/game/hero/HeroAnmComp.ts +++ b/assets/script/game/hero/HeroAnmComp.ts @@ -41,6 +41,13 @@ export default class HeroAnmComp extends Component { this._hasStop = true; } onAnimationFinished(type: Animation.EventType, state: AnimationState) { + if (state.name === "max0" || state.name === "max1") { + // 大招播放结束,清除 HeroViewComp 的置顶标记,恢复 MoveSystem 统一排序 + const viewComp = this.node.getComponent(HeroViewComp) || this.node.getComponentInParent(HeroViewComp); + if (viewComp) { + viewComp.isCastingMax = false; + } + } if (state.name != "idle" && state.name != "move") { this.anmcon.play(this.default_anim) } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 726a7da7..55cf69f8 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -43,6 +43,8 @@ export class HeroViewComp extends CCComp { lastBarUpdateTime: number = 0; // 最后一次血条/蓝条/护盾更新时间 // ==================== UI 节点引用 ==================== private topBar: HeroTopBarComp = null!; + /** 是否正在播放大招动画(用于渲染层级置顶,由 HeroAnmComp 播放结束时清除) */ + public isCastingMax: boolean = false; // ==================== 直接访问 HeroAttrsComp ==================== get model() { @@ -356,6 +358,8 @@ export class HeroViewComp extends CCComp { // 添加安全检查 if (!this.model) return; + this.isCastingMax = false; + // 防止重复触发 if (this.model.is_count_dead) return; this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用 @@ -438,6 +442,7 @@ export class HeroViewComp extends CCComp { if (act === "") return; switch (act) { case "max": + this.isCastingMax = true; this.as.max() break case "atk": @@ -487,6 +492,7 @@ export class HeroViewComp extends CCComp { } } reset() { + this.isCastingMax = false; // 清理残留的定时器和缓动 this.unscheduleAllCallbacks(); Tween.stopAllByTarget(this.node); diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 1b21988e..a4bc415f 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -49,7 +49,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate private readonly renderSortInterval = 0.05; private lastRenderSortAt = 0; private heroViewMatcher: ecs.IMatcher | null = null; - private readonly renderEntries: { node: Node; bossPriority: number; frontScore: number; spawnOrder: number; eid: number; laneScore: number }[] = []; + private readonly renderEntries: { node: Node; bossPriority: number; frontScore: number; spawnOrder: number; eid: number; laneScore: number; isCastingMax: boolean }[] = []; private renderEntryCount = 0; // ======================== 英雄编队排队 ======================== @@ -407,7 +407,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate const entryIndex = this.renderEntryCount; let entry = this.renderEntries[entryIndex]; if (!entry) { - entry = { node: actorView.node, bossPriority: 0, frontScore: 0, spawnOrder: 0, eid: 0, laneScore: 0 }; + entry = { node: actorView.node, bossPriority: 0, frontScore: 0, spawnOrder: 0, eid: 0, laneScore: 0, isCastingMax: false }; this.renderEntries.push(entry); } entry.node = actorView.node; @@ -415,11 +415,14 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate entry.frontScore = frontScore; entry.spawnOrder = spawnOrder; entry.eid = e.eid; + entry.isCastingMax = actorView.isCastingMax; this.renderEntryCount += 1; }); this.renderEntries.length = this.renderEntryCount; this.renderEntries.sort((a, b) => { + // 正在播放大招的英雄排在最后,siblingIndex 越大渲染层级越靠上 + if (a.isCastingMax !== b.isCastingMax) return a.isCastingMax ? 1 : -1; // Y轴靠下的(laneScore 较大)应该在后面,从而渲染在上面 if (Math.abs(a.laneScore - b.laneScore) > 10) return a.laneScore - b.laneScore; if (a.frontScore !== b.frontScore) return a.frontScore - b.frontScore;