refactor(hero&mission): 调整英雄站位逻辑与配置
1. 修改游戏地平线Y轴偏移至100,适配新的UI布局 2. 为英雄属性组件添加分路与排位字段并初始化 3. 重构英雄站位分配逻辑,使用新增字段记录英雄位置 4. 更新地图与UI预制体的布局偏移适配新的游戏地平线
This commit is contained in:
@@ -587,7 +587,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 107.444,
|
"y": 237.503,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -723,7 +723,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 336.936,
|
"y": 428.991,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -862,7 +862,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 102.513,
|
"y": 193.723,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -978,7 +978,7 @@
|
|||||||
"_left": 0,
|
"_left": 0,
|
||||||
"_right": 0,
|
"_right": 0,
|
||||||
"_top": 0,
|
"_top": 0,
|
||||||
"_bottom": 152.513,
|
"_bottom": 243.723,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
"_isAbsLeft": true,
|
"_isAbsLeft": true,
|
||||||
@@ -1037,7 +1037,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 102.513,
|
"y": 193.723,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1153,7 +1153,7 @@
|
|||||||
"_left": 0,
|
"_left": 0,
|
||||||
"_right": 0,
|
"_right": 0,
|
||||||
"_top": 0,
|
"_top": 0,
|
||||||
"_bottom": 152.513,
|
"_bottom": 243.723,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
"_isAbsLeft": true,
|
"_isAbsLeft": true,
|
||||||
@@ -1317,6 +1317,8 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "e7P5mh6mhLga+0q7X7vlTP",
|
"fileId": "e7P5mh6mhLga+0q7X7vlTP",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1346,7 +1348,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": -233.935,
|
"y": -120,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1462,7 +1464,7 @@
|
|||||||
"_left": 0,
|
"_left": 0,
|
||||||
"_right": 0,
|
"_right": 0,
|
||||||
"_top": 0,
|
"_top": 0,
|
||||||
"_bottom": -183.935,
|
"_bottom": -70,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
"_isAbsLeft": true,
|
"_isAbsLeft": true,
|
||||||
@@ -1490,6 +1492,8 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "6bE0ieRMBGyYHdxvuJ03FA",
|
"fileId": "6bE0ieRMBGyYHdxvuJ03FA",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1201,7 +1201,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 309.135,
|
"y": 242.874,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1254,7 +1254,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -350,
|
"x": -350,
|
||||||
"y": 93.364,
|
"y": 221.748,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1324,8 +1324,8 @@
|
|||||||
"_target": null,
|
"_target": null,
|
||||||
"_left": 10,
|
"_left": 10,
|
||||||
"_right": 10,
|
"_right": 10,
|
||||||
"_top": 21.635999999999996,
|
"_top": -106.74799999999999,
|
||||||
"_bottom": 8.364000000000004,
|
"_bottom": 136.748,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
"_isAbsLeft": true,
|
"_isAbsLeft": true,
|
||||||
@@ -1357,7 +1357,7 @@
|
|||||||
"__id__": 53
|
"__id__": 53
|
||||||
},
|
},
|
||||||
"_resizeMode": 0,
|
"_resizeMode": 0,
|
||||||
"_layoutType": 1,
|
"_layoutType": 3,
|
||||||
"_cellSize": {
|
"_cellSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 40,
|
"width": 40,
|
||||||
@@ -1369,10 +1369,10 @@
|
|||||||
"_paddingTop": 0,
|
"_paddingTop": 0,
|
||||||
"_paddingBottom": 0,
|
"_paddingBottom": 0,
|
||||||
"_spacingX": 5,
|
"_spacingX": 5,
|
||||||
"_spacingY": 0,
|
"_spacingY": 20,
|
||||||
"_verticalDirection": 1,
|
"_verticalDirection": 1,
|
||||||
"_horizontalDirection": 0,
|
"_horizontalDirection": 0,
|
||||||
"_constraint": 0,
|
"_constraint": 1,
|
||||||
"_constraintNum": 2,
|
"_constraintNum": 2,
|
||||||
"_affectedByScale": false,
|
"_affectedByScale": false,
|
||||||
"_isAlign": true,
|
"_isAlign": true,
|
||||||
@@ -2126,7 +2126,7 @@
|
|||||||
"_left": 0,
|
"_left": 0,
|
||||||
"_right": 0,
|
"_right": 0,
|
||||||
"_top": 0,
|
"_top": 0,
|
||||||
"_bottom": 309.135,
|
"_bottom": 242.874,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
"_isAbsLeft": true,
|
"_isAbsLeft": true,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export enum BoxSet {
|
|||||||
LETF_END = -360,
|
LETF_END = -360,
|
||||||
RIGHT_END = 360,
|
RIGHT_END = 360,
|
||||||
//游戏地平线
|
//游戏地平线
|
||||||
GAME_LINE = 0,
|
GAME_LINE = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum FacSet {
|
export enum FacSet {
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
maxSkillDistance: number = 0; // 最远技能攻击距离(缓存,受MP影响)
|
maxSkillDistance: number = 0; // 最远技能攻击距离(缓存,受MP影响)
|
||||||
minSkillDistance: number = 0; // 最近技能攻击距离(缓存,不受MP影响,用于停止位置判断)
|
minSkillDistance: number = 0; // 最近技能攻击距离(缓存,不受MP影响,用于停止位置判断)
|
||||||
|
|
||||||
|
// ==================== 阵型位置 ====================
|
||||||
|
lane: number = -1; // 所在分路:0上路, 1中路, 2下路
|
||||||
|
lane_index: number = -1; // 所在路中的排位:0前排, 1后排
|
||||||
|
|
||||||
// ==================== 标记状态 ====================
|
// ==================== 标记状态 ====================
|
||||||
is_dead: boolean = false;
|
is_dead: boolean = false;
|
||||||
is_count_dead: boolean = false;
|
is_count_dead: boolean = false;
|
||||||
@@ -308,6 +312,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.maxSkillDistance = 0;
|
this.maxSkillDistance = 0;
|
||||||
this.minSkillDistance = 0;
|
this.minSkillDistance = 0;
|
||||||
|
|
||||||
|
this.lane = -1;
|
||||||
|
this.lane_index = -1;
|
||||||
|
|
||||||
this.is_dead = false;
|
this.is_dead = false;
|
||||||
this.is_count_dead = false;
|
this.is_count_dead = false;
|
||||||
this.is_atking = false;
|
this.is_atking = false;
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
const col = Math.floor(slotIndex / 3);
|
const col = Math.floor(slotIndex / 3);
|
||||||
const laneIdx = lanePriority[slotIndex % 3];
|
const laneIdx = lanePriority[slotIndex % 3];
|
||||||
|
|
||||||
|
// 动态更新英雄位置数据,为战斗面板排序提供依据
|
||||||
|
model.lane = laneIdx;
|
||||||
|
model.lane_index = col;
|
||||||
|
|
||||||
const targetY = BoxSet.GAME_LINE + laneOffsets[laneIdx];
|
const targetY = BoxSet.GAME_LINE + laneOffsets[laneIdx];
|
||||||
const targetX = this.heroFrontAnchorX - col * this.heroAllySpacingX;
|
const targetX = this.heroFrontAnchorX - col * this.heroAllySpacingX;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
/** 远程(含中程)英雄起始出生 X 坐标 */
|
/** 远程(含中程)英雄起始出生 X 坐标 */
|
||||||
private static readonly HERO_SPAWN_START_RANGED_X = -320
|
private static readonly HERO_SPAWN_START_RANGED_X = -320
|
||||||
/** 三路高度偏移(上路, 中路, 下路) */
|
/** 三路高度偏移(上路, 中路, 下路) */
|
||||||
private static readonly HERO_LANE_Y_OFFSETS = [100, 0, -100]
|
private static readonly HERO_LANE_Y_OFFSETS = [ BoxSet.GAME_LINE+90, BoxSet.GAME_LINE, BoxSet.GAME_LINE-90]
|
||||||
/** 每路前排容量 */
|
/** 每路前排容量 */
|
||||||
private static readonly HERO_LANE_CAP = 2
|
private static readonly HERO_LANE_CAP = 2
|
||||||
/** 同路内 X 间距 */
|
/** 同路内 X 间距 */
|
||||||
@@ -131,6 +131,8 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
if (model.is_dead) {
|
if (model.is_dead) {
|
||||||
view.alive();
|
view.alive();
|
||||||
const { lane, indexInLane } = this.pickLaneForHero(model.hero_uuid, [hero.eid]);
|
const { lane, indexInLane } = this.pickLaneForHero(model.hero_uuid, [hero.eid]);
|
||||||
|
model.lane = lane;
|
||||||
|
model.lane_index = indexInLane;
|
||||||
const landingPos = this.resolveHeroLandingPos(model.hero_uuid, lane, indexInLane);
|
const landingPos = this.resolveHeroLandingPos(model.hero_uuid, lane, indexInLane);
|
||||||
// 不再直接设置位置,而是播放下落入场动画
|
// 不再直接设置位置,而是播放下落入场动画
|
||||||
// 计算出出生点(空中)
|
// 计算出出生点(空中)
|
||||||
@@ -168,6 +170,7 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态分配英雄上场的路和排位(优先中路 -> 上路 -> 下路)
|
* 动态分配英雄上场的路和排位(优先中路 -> 上路 -> 下路)
|
||||||
|
* 标记英雄的6个登录点
|
||||||
* @param uuid 英雄 UUID
|
* @param uuid 英雄 UUID
|
||||||
* @param excludeEids 排除计算的实体ID数组(避免复活或合成时把自己算成占据的位置)
|
* @param excludeEids 排除计算的实体ID数组(避免复活或合成时把自己算成占据的位置)
|
||||||
*/
|
*/
|
||||||
@@ -177,40 +180,32 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
return m && !m.is_dead && !excludeEids.includes(h.eid);
|
return m && !m.is_dead && !excludeEids.includes(h.eid);
|
||||||
});
|
});
|
||||||
|
|
||||||
const counts = [0, 0, 0];
|
// 记录6个位置点的占用情况 [lane][indexInLane]
|
||||||
const baseY = HeroPos[0].pos.y;
|
const occupied = [
|
||||||
|
[false, false], // 上路 0
|
||||||
|
[false, false], // 中路 1
|
||||||
|
[false, false] // 下路 2
|
||||||
|
];
|
||||||
|
|
||||||
for (const h of heroes) {
|
for (const h of heroes) {
|
||||||
const view = h.get(HeroViewComp);
|
const m = h.get(HeroAttrsComp);
|
||||||
if (!view || !view.node) continue;
|
if (m && m.lane >= 0 && m.lane <= 2 && m.lane_index >= 0 && m.lane_index <= 1) {
|
||||||
|
occupied[m.lane][m.lane_index] = true;
|
||||||
let y = view.node.position.y;
|
|
||||||
// 处理正在掉落状态的英雄(y 值偏高)
|
|
||||||
if (y > baseY + 150) {
|
|
||||||
y -= MissionHeroCompComp.HERO_DROP_HEIGHT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let nearest = 1, best = Infinity;
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
const d = Math.abs(y - (baseY + MissionHeroCompComp.HERO_LANE_Y_OFFSETS[i]));
|
|
||||||
if (d < best) {
|
|
||||||
best = d;
|
|
||||||
nearest = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
counts[nearest]++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 优先中路(1) -> 上路(0) -> 下路(2)
|
// 优先中路(1) -> 上路(0) -> 下路(2)
|
||||||
const priority = [1, 0, 2];
|
const priority = [1, 0, 2];
|
||||||
for (const lane of priority) {
|
for (const lane of priority) {
|
||||||
if (counts[lane] < MissionHeroCompComp.HERO_LANE_CAP) {
|
for (let indexInLane = 0; indexInLane < MissionHeroCompComp.HERO_LANE_CAP; indexInLane++) {
|
||||||
return { lane, indexInLane: counts[lane] };
|
if (!occupied[lane][indexInLane]) {
|
||||||
|
return { lane, indexInLane };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 溢出:仍放中路,沿 X 继续排
|
// 溢出:仍放中路,沿 X 继续排
|
||||||
return { lane: 1, indexInLane: counts[1] };
|
return { lane: 1, indexInLane: 2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,6 +230,8 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
// 召唤完成后,派发事件以更新英雄面板
|
// 召唤完成后,派发事件以更新英雄面板
|
||||||
const model = hero.get(HeroAttrsComp);
|
const model = hero.get(HeroAttrsComp);
|
||||||
if (model) {
|
if (model) {
|
||||||
|
model.lane = lane;
|
||||||
|
model.lane_index = indexInLane;
|
||||||
oops.message.dispatchEvent(GameEvent.MasterCalled, {
|
oops.message.dispatchEvent(GameEvent.MasterCalled, {
|
||||||
eid: hero.eid,
|
eid: hero.eid,
|
||||||
model: model
|
model: model
|
||||||
@@ -305,6 +302,8 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
// 召唤完成后,派发事件以更新英雄面板
|
// 召唤完成后,派发事件以更新英雄面板
|
||||||
const model = hero.get(HeroAttrsComp);
|
const model = hero.get(HeroAttrsComp);
|
||||||
if (model) {
|
if (model) {
|
||||||
|
model.lane = lane;
|
||||||
|
model.lane_index = indexInLane;
|
||||||
model.ap = Math.max(0, ap);
|
model.ap = Math.max(0, ap);
|
||||||
model.hp_max = Math.max(1, hp_max);
|
model.hp_max = Math.max(1, hp_max);
|
||||||
model.hp = model.hp_max;
|
model.hp = model.hp_max;
|
||||||
|
|||||||
Reference in New Issue
Block a user