fix(hero): 修复大招播放结束后未取消层级置顶的问题
1. 新增isCastingMax标记跟踪大招播放状态,在释放大招时设置该标记 2. 在动画播放结束回调中,当大招动画播放完成时清除置顶标记 3. 调整渲染排序逻辑,将大招播放中的英雄置于渲染层级最下方 4. 在角色死亡和重置时同步重置置顶标记
This commit is contained in:
@@ -41,6 +41,13 @@ export default class HeroAnmComp extends Component {
|
|||||||
this._hasStop = true;
|
this._hasStop = true;
|
||||||
}
|
}
|
||||||
onAnimationFinished(type: Animation.EventType, state: AnimationState) {
|
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") {
|
if (state.name != "idle" && state.name != "move") {
|
||||||
this.anmcon.play(this.default_anim)
|
this.anmcon.play(this.default_anim)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
lastBarUpdateTime: number = 0; // 最后一次血条/蓝条/护盾更新时间
|
lastBarUpdateTime: number = 0; // 最后一次血条/蓝条/护盾更新时间
|
||||||
// ==================== UI 节点引用 ====================
|
// ==================== UI 节点引用 ====================
|
||||||
private topBar: HeroTopBarComp = null!;
|
private topBar: HeroTopBarComp = null!;
|
||||||
|
/** 是否正在播放大招动画(用于渲染层级置顶,由 HeroAnmComp 播放结束时清除) */
|
||||||
|
public isCastingMax: boolean = false;
|
||||||
|
|
||||||
// ==================== 直接访问 HeroAttrsComp ====================
|
// ==================== 直接访问 HeroAttrsComp ====================
|
||||||
get model() {
|
get model() {
|
||||||
@@ -356,6 +358,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 添加安全检查
|
// 添加安全检查
|
||||||
if (!this.model) return;
|
if (!this.model) return;
|
||||||
|
|
||||||
|
this.isCastingMax = false;
|
||||||
|
|
||||||
// 防止重复触发
|
// 防止重复触发
|
||||||
if (this.model.is_count_dead) return;
|
if (this.model.is_count_dead) return;
|
||||||
this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用
|
this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用
|
||||||
@@ -438,6 +442,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
if (act === "") return;
|
if (act === "") return;
|
||||||
switch (act) {
|
switch (act) {
|
||||||
case "max":
|
case "max":
|
||||||
|
this.isCastingMax = true;
|
||||||
this.as.max()
|
this.as.max()
|
||||||
break
|
break
|
||||||
case "atk":
|
case "atk":
|
||||||
@@ -487,6 +492,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
this.isCastingMax = false;
|
||||||
// 清理残留的定时器和缓动
|
// 清理残留的定时器和缓动
|
||||||
this.unscheduleAllCallbacks();
|
this.unscheduleAllCallbacks();
|
||||||
Tween.stopAllByTarget(this.node);
|
Tween.stopAllByTarget(this.node);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
private readonly renderSortInterval = 0.05;
|
private readonly renderSortInterval = 0.05;
|
||||||
private lastRenderSortAt = 0;
|
private lastRenderSortAt = 0;
|
||||||
private heroViewMatcher: ecs.IMatcher | null = null;
|
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;
|
private renderEntryCount = 0;
|
||||||
|
|
||||||
// ======================== 英雄编队排队 ========================
|
// ======================== 英雄编队排队 ========================
|
||||||
@@ -407,7 +407,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
const entryIndex = this.renderEntryCount;
|
const entryIndex = this.renderEntryCount;
|
||||||
let entry = this.renderEntries[entryIndex];
|
let entry = this.renderEntries[entryIndex];
|
||||||
if (!entry) {
|
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);
|
this.renderEntries.push(entry);
|
||||||
}
|
}
|
||||||
entry.node = actorView.node;
|
entry.node = actorView.node;
|
||||||
@@ -415,11 +415,14 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
entry.frontScore = frontScore;
|
entry.frontScore = frontScore;
|
||||||
entry.spawnOrder = spawnOrder;
|
entry.spawnOrder = spawnOrder;
|
||||||
entry.eid = e.eid;
|
entry.eid = e.eid;
|
||||||
|
entry.isCastingMax = actorView.isCastingMax;
|
||||||
this.renderEntryCount += 1;
|
this.renderEntryCount += 1;
|
||||||
});
|
});
|
||||||
this.renderEntries.length = this.renderEntryCount;
|
this.renderEntries.length = this.renderEntryCount;
|
||||||
|
|
||||||
this.renderEntries.sort((a, b) => {
|
this.renderEntries.sort((a, b) => {
|
||||||
|
// 正在播放大招的英雄排在最后,siblingIndex 越大渲染层级越靠上
|
||||||
|
if (a.isCastingMax !== b.isCastingMax) return a.isCastingMax ? 1 : -1;
|
||||||
// Y轴靠下的(laneScore 较大)应该在后面,从而渲染在上面
|
// Y轴靠下的(laneScore 较大)应该在后面,从而渲染在上面
|
||||||
if (Math.abs(a.laneScore - b.laneScore) > 10) return a.laneScore - b.laneScore;
|
if (Math.abs(a.laneScore - b.laneScore) > 10) return a.laneScore - b.laneScore;
|
||||||
if (a.frontScore !== b.frontScore) return a.frontScore - b.frontScore;
|
if (a.frontScore !== b.frontScore) return a.frontScore - b.frontScore;
|
||||||
|
|||||||
Reference in New Issue
Block a user