feat: 为英雄和怪物添加下落入场动画

- 在 MissionHeroComp 和 MissionMonComp 中定义下落高度常量
- 修改英雄和怪物的加载方法,接受目标落地高度参数
- 使用 Tween 实现平滑下落动画,下落距离越大持续时间越长
- 下落期间禁用移动和碰撞器,落地后恢复
- 为怪物添加随机下落高度偏移,减轻重叠感
This commit is contained in:
panw
2026-03-19 09:11:11 +08:00
parent a20e5db00b
commit 1522e93585
4 changed files with 51 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ const { ccclass, property } = _decorator;
@ccclass('MissionHeroCompComp')
@ecs.register('MissionHeroComp', false)
export class MissionHeroCompComp extends CCComp {
private static readonly HERO_DROP_HEIGHT = 260
timer:Timer=new Timer(2)
Friend_is_dead:boolean=false
current_hero_uuid:number=0
@@ -59,8 +60,9 @@ export class MissionHeroCompComp extends CCComp {
let hero_pos=0
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = HeroPos[hero_pos].pos;
hero.load(pos,scale,uuid);
let landingPos:Vec3 = HeroPos[hero_pos].pos;
let spawnPos:Vec3 = v3(landingPos.x, landingPos.y + MissionHeroCompComp.HERO_DROP_HEIGHT, 0);
hero.load(spawnPos,scale,uuid,landingPos.y);
}
@@ -70,4 +72,4 @@ export class MissionHeroCompComp extends CCComp {
reset() {
// this.node.destroy();
}
}
}

View File

@@ -17,6 +17,7 @@ const { ccclass, property } = _decorator;
@ecs.register('MissionMonComp', false)
export class MissionMonCompComp extends CCComp {
private static readonly BOSS_RENDER_PRIORITY = 1000000;
private static readonly MON_DROP_HEIGHT = 300;
@property({ tooltip: "是否启用调试日志" })
private debugMode: boolean = false;
@@ -195,11 +196,13 @@ export class MissionMonCompComp extends CCComp {
let mon = ecs.getEntity<Monster>(Monster);
let scale = -1;
// 按生成序号做横向错列,减轻重叠感
let pos: Vec3 = v3(MonStart.START_X, BoxSet.GAME_LINE, 0);
const landingY = BoxSet.GAME_LINE + (isBoss ? 6 : 0);
const dropOffset = MissionMonCompComp.MON_DROP_HEIGHT + Math.floor(Math.random() * 40);
let pos: Vec3 = v3(MonStart.START_X, landingY + dropOffset, 0);
// 递增全局生成顺序,做溢出保护
this.globalSpawnOrder = (this.globalSpawnOrder + 1) % 999;
mon.load(pos, scale, uuid, isBoss);
mon.load(pos, scale, uuid, isBoss, landingY);
const move = mon.get(MoveComp);
if (move) {
move.spawnOrder = isBoss