refactor(map,hero): 调整怪物出生参数与UI显示逻辑
1. 调整怪物出生点X坐标和掉落高度默认值 2. 修复英雄血条UI层级问题,强制置于顶层 3. 优化血条提示框的Y轴显示位置 4. 简化怪物死亡飞出动画,移除多余的角度重置 5. 重构怪物下落逻辑,拆分完成回调,处理无下落距离的情况
This commit is contained in:
@@ -212,30 +212,43 @@ 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));
|
||||
|
||||
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;
|
||||
// 落地后启用怪物碰撞分组
|
||||
if (collider) {
|
||||
collider.enabled = true;
|
||||
collider.group = BoxSet.MONSTER;
|
||||
collider.apply();
|
||||
}
|
||||
|
||||
// 落地后触发 call 技能
|
||||
SkillTriggerHelper.trigger(SkillTriggerType.Call, model, view);
|
||||
};
|
||||
|
||||
// 停止旧动画后执行下落 tween,避免复用节点时动画叠加
|
||||
Tween.stopAllByTarget(node);
|
||||
tween(node)
|
||||
.to(dropDuration, { position: v3(pos.x, dropToY, 0) })
|
||||
.call(() => {
|
||||
if (!node || !node.isValid) return;
|
||||
// 落地后锁定最终位置,切换到落地完成状态
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
view.playEnd("down");
|
||||
|
||||
move.moving = true;
|
||||
// 落地后启用怪物碰撞分组
|
||||
if (collider) {
|
||||
collider.enabled = true;
|
||||
collider.group = BoxSet.MONSTER;
|
||||
collider.apply();
|
||||
}
|
||||
|
||||
// 落地后触发 call 技能
|
||||
SkillTriggerHelper.trigger(SkillTriggerType.Call, model, view);
|
||||
})
|
||||
.start();
|
||||
|
||||
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++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user