fix(map): correct hero position calculation and loop order
修复了MissionHeroComp的遍历顺序,同时修正了MissionCardComp中的节点索引计算逻辑,匹配实际的视觉排布和MoveComp中的赋值规则,添加了调试日志方便排查位置问题。
This commit is contained in:
@@ -901,9 +901,26 @@ export class MissionCardComp extends CCComp {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算目标 node_index: lane_index=0 对应 1排(1-3), lane_index=1 对应 2排(4-6)
|
// MoveComp.ts 里的 assignment:
|
||||||
// lane=0 上路, lane=1 中路, lane=2 下路
|
// lanePriority = [1, 0, 2]; // slotIndex 0->中路(1), 1->上路(0), 2->下路(2)
|
||||||
const expectedNodeIndex = model.lane_index * 3 + model.lane + 1;
|
// laneIdx = lanePriority[slotIndex % 3];
|
||||||
|
// col = Math.floor(slotIndex / 3);
|
||||||
|
// model.lane = laneIdx;
|
||||||
|
// model.lane_index = col;
|
||||||
|
//
|
||||||
|
// 节点顺序预期:
|
||||||
|
// node_index=1 对应 1排上路 (lane=0, lane_index=0)
|
||||||
|
// node_index=2 对应 1排中路 (lane=1, lane_index=0)
|
||||||
|
// node_index=3 对应 1排下路 (lane=2, lane_index=0)
|
||||||
|
// node_index=4 对应 2排上路 (lane=0, lane_index=1)
|
||||||
|
// node_index=5 对应 2排中路 (lane=1, lane_index=1)
|
||||||
|
// node_index=6 对应 2排下路 (lane=2, lane_index=1)
|
||||||
|
// 因为 1排中路 在视觉上是最前面的,实际按路排(上/中/下):
|
||||||
|
const laneOrder = model.lane === 0 ? 0 : (model.lane === 1 ? 1 : 2);
|
||||||
|
const expectedNodeIndex = model.lane_index * 3 + laneOrder + 1;
|
||||||
|
|
||||||
|
mLogger.log(this.debugMode, "MissionCardComp", `ensureHeroInfoPanel calculation: lane=${model.lane}, lane_index=${model.lane_index} -> expectedNodeIndex=${expectedNodeIndex}`);
|
||||||
|
|
||||||
const comp = this.cachedHInfoComps.get(expectedNodeIndex);
|
const comp = this.cachedHInfoComps.get(expectedNodeIndex);
|
||||||
|
|
||||||
if (!comp) {
|
if (!comp) {
|
||||||
|
|||||||
@@ -197,8 +197,8 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
|
|
||||||
// 优先中路(1) -> 上路(0) -> 下路(2)
|
// 优先中路(1) -> 上路(0) -> 下路(2)
|
||||||
const priority = [1, 0, 2];
|
const priority = [1, 0, 2];
|
||||||
for (const lane of priority) {
|
for (let indexInLane = 0; indexInLane < MissionHeroCompComp.HERO_LANE_CAP; indexInLane++) {
|
||||||
for (let indexInLane = 0; indexInLane < MissionHeroCompComp.HERO_LANE_CAP; indexInLane++) {
|
for (const lane of priority) {
|
||||||
if (!occupied[lane][indexInLane]) {
|
if (!occupied[lane][indexInLane]) {
|
||||||
return { lane, indexInLane };
|
return { lane, indexInLane };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user