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;