refactor(map/hero): 重构英雄位置管理逻辑,移除lane相关字段
重构了英雄分路排位的旧实现,改用硬编码的点位数组管理英雄站位,移除了HeroAttrsComp中的lane和lane_index字段,简化了英雄位置分配、UI面板绑定的逻辑,提升代码可维护性。
This commit is contained in:
@@ -46,6 +46,8 @@ interface MoveFacConfig {
|
||||
retreatBackX: number;
|
||||
}
|
||||
|
||||
import { MissionHeroCompComp } from "../map/MissionHeroComp";
|
||||
|
||||
@ecs.register('MoveSystem')
|
||||
export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
private readonly heroFrontAnchorX = -200;
|
||||
@@ -249,20 +251,12 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
|
||||
const slotIndex = Math.max(0, allAllies.findIndex(entity => entity === self));
|
||||
|
||||
const lanePriority = [1, 0, 2]; // 中路优先,其次上路,最后下路
|
||||
const laneOffsets = [100, 0, -100];
|
||||
// 优先中前(1) -> 上前(0) -> 下前(2) -> 中后(4) -> 上后(3) -> 下后(5)
|
||||
const slotPriority = [1, 0, 2, 4, 3, 5];
|
||||
const posIndex = slotPriority[slotIndex % 6];
|
||||
const pos = MissionHeroCompComp.HERO_POSITIONS[posIndex];
|
||||
|
||||
const col = Math.floor(slotIndex / 3);
|
||||
const laneIdx = lanePriority[slotIndex % 3];
|
||||
|
||||
// 动态更新英雄位置数据,为战斗面板排序提供依据
|
||||
model.lane = laneIdx;
|
||||
model.lane_index = col;
|
||||
|
||||
const targetY = BoxSet.GAME_LINE + laneOffsets[laneIdx];
|
||||
const targetX = this.heroFrontAnchorX - col * this.heroAllySpacingX;
|
||||
|
||||
return { targetX, targetY };
|
||||
return { targetX: pos.x, targetY: pos.y };
|
||||
}
|
||||
|
||||
private moveToSlot(view: HeroViewComp, move: MoveComp, model: HeroAttrsComp, targetX: number) {
|
||||
|
||||
Reference in New Issue
Block a user