修改了很多

This commit is contained in:
2025-03-27 23:25:10 +08:00
parent 3a15541170
commit 67704725b2
40 changed files with 9140 additions and 4253 deletions

View File

@@ -24,6 +24,9 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
const shouldStop = enemiesStop;
view.is_atking = shouldStop;
// 更新渲染层级
this.updateRenderOrder(e);
// 同步状态
if (!shouldStop) {
if(view.is_stop||view.is_dead) return //停止移动或者死亡不移动
@@ -134,4 +137,29 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
}
});
}
/** 更新渲染层级 */
private updateRenderOrder(entity: ecs.Entity) {
const current = entity.get(HeroViewComp);
// 查找所有单位
const allUnits = ecs.query(ecs.allOf(HeroViewComp)).filter(e => {
const other = e.get(HeroViewComp);
return other.fac === current.fac; // 按阵营分组
});
// 按y坐标从大到小排序y坐标越小显示在上层
const sortedUnits = allUnits.sort((a, b) => {
const posA = a.get(HeroViewComp).node.position.y;
const posB = b.get(HeroViewComp).node.position.y;
return posB - posA; // 修改排序顺序
});
// 设置渲染顺序
// 根据y坐标设置层级y坐标越小的显示在上层
const index = sortedUnits.findIndex(e => e === entity);
current.node.setSiblingIndex(index);
}
}