refactor(map,hero): 调整怪物出生参数与UI显示逻辑
1. 调整怪物出生点X坐标和掉落高度默认值 2. 修复英雄血条UI层级问题,强制置于顶层 3. 优化血条提示框的Y轴显示位置 4. 简化怪物死亡飞出动画,移除多余的角度重置 5. 重构怪物下落逻辑,拆分完成回调,处理无下落距离的情况
This commit is contained in:
@@ -136,6 +136,9 @@ export class HeroViewComp extends CCComp {
|
||||
if(this.model.fac==FacSet.HERO){
|
||||
hpNode.getChildByName("Bar").getComponent(Sprite).color=new Color("#2ECC71")
|
||||
}
|
||||
|
||||
// 确保血条等UI始终在最上层显示
|
||||
this.top_node.setSiblingIndex(999);
|
||||
}
|
||||
|
||||
|
||||
@@ -311,8 +314,8 @@ export class HeroViewComp extends CCComp {
|
||||
halfHeight = transform.height / 2;
|
||||
}
|
||||
|
||||
// 起点设为怪物中心位置 + 20偏移
|
||||
let ny = this.node.position.y + halfHeight + 20;
|
||||
// 起点设为怪物中心偏下位置,使其在血条下方
|
||||
let ny = this.node.position.y + halfHeight - 15;
|
||||
let pos = v3(x, ny, 0);
|
||||
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON);
|
||||
}
|
||||
@@ -480,9 +483,8 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
// 死亡往后飞出屏幕动画
|
||||
tween(this.node)
|
||||
.by(0.5, { position: v3(dirX, 700, 0), angle: isHero ? 360 : -360 }, { easing: "quadOut" })
|
||||
.by(0.5, { position: v3(dirX, 700, 0) }, { easing: "quadOut" })
|
||||
.call(() => {
|
||||
this.node.angle = 0; // 重置角度
|
||||
if (isHero) {
|
||||
// 将英雄移到玩家看不到的墓地,留待下回合上场
|
||||
this.node.setPosition(v3(-2000, -2000, 0));
|
||||
|
||||
@@ -212,17 +212,16 @@ export class Monster extends ecs.Entity {
|
||||
|
||||
// 依据下落距离自适应入场时长,确保观感一致
|
||||
const dropDistance = Math.abs(pos.y - dropToY);
|
||||
const dropDuration = Math.max(0.18, Math.min(0.38, dropDistance / 1200));
|
||||
|
||||
// 停止旧动画后执行下落 tween,避免复用节点时动画叠加
|
||||
Tween.stopAllByTarget(node);
|
||||
tween(node)
|
||||
.to(dropDuration, { position: v3(pos.x, dropToY, 0) })
|
||||
.call(() => {
|
||||
const onDropComplete = () => {
|
||||
if (!node || !node.isValid) return;
|
||||
// 落地后锁定最终位置,切换到落地完成状态
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
if (dropDistance > 0) {
|
||||
view.playEnd("down");
|
||||
} else {
|
||||
view.status_change("move"); // 直接进入移动状态
|
||||
}
|
||||
|
||||
move.moving = true;
|
||||
// 落地后启用怪物碰撞分组
|
||||
@@ -234,8 +233,22 @@ export class Monster extends ecs.Entity {
|
||||
|
||||
// 落地后触发 call 技能
|
||||
SkillTriggerHelper.trigger(SkillTriggerType.Call, model, view);
|
||||
})
|
||||
};
|
||||
|
||||
// 停止旧动画后执行下落 tween,避免复用节点时动画叠加
|
||||
Tween.stopAllByTarget(node);
|
||||
|
||||
if (dropDistance > 0) {
|
||||
const dropDuration = Math.max(0.18, Math.min(0.38, dropDistance / 1200));
|
||||
tween(node)
|
||||
.to(dropDuration, { position: v3(pos.x, dropToY, 0) })
|
||||
.call(onDropComplete)
|
||||
.start();
|
||||
} else {
|
||||
// 没有下落距离,直接出现在目标位置并开始移动
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
onDropComplete();
|
||||
}
|
||||
// 维护关卡内怪物数量统计
|
||||
smc.vmdata.mission_data.mon_num++
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ export class MissionMonCompComp extends CCComp {
|
||||
// ======================== 常量 ========================
|
||||
|
||||
/** 怪物出生点起点 X */
|
||||
private static readonly MON_SPAWN_START_X = 280;
|
||||
private static readonly MON_SPAWN_START_X = 460;
|
||||
/** 怪物出生的 X 间距 */
|
||||
private static readonly MON_SPAWN_GAP_X = 50;
|
||||
/** 怪物出生掉落高度 */
|
||||
private static readonly MON_DROP_HEIGHT = 280;
|
||||
private static readonly MON_DROP_HEIGHT = 0;
|
||||
/** 6路高度偏移(在三路的y轴范围内,实现 6路 进军) */
|
||||
private static readonly LANE_Y_OFFSETS = [100, 60, 20, -20, -60, -100];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user