refactor(MissionHeroComp): 重构英雄登场点位逻辑

1.  将动态生成的英雄站位改为硬编码固定3列位置
2.  更新站位分配优先级适配新的点位数组
3.  优化注释说明,明确点位规则和分配逻辑
This commit is contained in:
pan
2026-08-13 09:31:40 +08:00
parent 038abdc5d2
commit 011e7b3dde

View File

@@ -54,19 +54,16 @@ export class MissionHeroComp extends CCComp {
// ======================== 常量 ======================== // ======================== 常量 ========================
/** /**
* 英雄登场占位点: * 英雄登场占位点(固定 3 列)
* - 从 x=-300 开始,每个点位间隔 60x 向右递增表示更靠前) * - index 0/1/2 分别对应 x=-320/-260/-200
* - 分配规则:近战优先靠前(靠近 0 的高索引),远程/中程优先靠后(低索引)。 * - 分配规则:近战优先靠前(x 更大),远程/中程优先靠后(x 更小);
* 同类型按召唤先后从该类型的一侧开始依次填充。
*/ */
public static readonly HERO_POSITIONS: Vec3[] = (() => { public static readonly HERO_POSITIONS: Vec3[] = [
const startX = -300; v3(-320, BoxSet.GAME_LINE, 0),
const step = 60; v3(-260, BoxSet.GAME_LINE, 0),
const positions: Vec3[] = []; v3(-200, BoxSet.GAME_LINE, 0),
for (let i = 0; i < FightSet.HERO_MAX_NUM; i++) { ];
positions.push(v3(startX + i * step, BoxSet.GAME_LINE, 0));
}
return positions;
})();
/** 英雄出生时的掉落高度(从空中落到地面的像素差) */ /** 英雄出生时的掉落高度(从空中落到地面的像素差) */
private static readonly HERO_DROP_HEIGHT = 260 private static readonly HERO_DROP_HEIGHT = 260
@@ -218,8 +215,8 @@ export class MissionHeroComp extends CCComp {
// 近战优先靠前x 更大,索引更大);远程/中程优先靠后x 更小,索引更小) // 近战优先靠前x 更大,索引更大);远程/中程优先靠后x 更小,索引更小)
const slotPriority = heroType === HType.Melee const slotPriority = heroType === HType.Melee
? [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ? [2, 1, 0]
: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; : [0, 1, 2];
for (const idx of slotPriority) { for (const idx of slotPriority) {
if (!occupied.has(idx) && MissionHeroComp.HERO_POSITIONS[idx]) { if (!occupied.has(idx) && MissionHeroComp.HERO_POSITIONS[idx]) {
return idx; return idx;