feat: 实现战斗准备阶段英雄复活与入场动画
在准备阶段开始时,通过 PhasePrepareStart 事件触发英雄状态重置: - 死亡英雄复活并恢复满血,播放下落入场动画 - 英雄实体在死亡时移至墓地并禁用碰撞,避免战斗逻辑干扰 - 更新英雄数量UI以反映复活后的状态
This commit is contained in:
@@ -155,6 +155,28 @@ export class Hero extends ecs.Entity {
|
||||
move.moving = false;
|
||||
hv.as.idle();
|
||||
|
||||
this.playDropAnim(pos, dropToY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放英雄入场(下落)动画
|
||||
* @param pos 初始位置(通常在空中)
|
||||
* @param dropToY 最终落地的 Y 坐标
|
||||
*/
|
||||
playDropAnim(pos: Vec3, dropToY: number) {
|
||||
const view = this.get(HeroViewComp);
|
||||
const node = view?.node;
|
||||
if (!node || !node.isValid) return;
|
||||
|
||||
const model = this.get(HeroAttrsComp);
|
||||
const move = this.get(MoveComp);
|
||||
const collider = node.getComponent(BoxCollider2D);
|
||||
|
||||
// 入场过程暂不参与碰撞,防止半空触发战斗逻辑
|
||||
if (collider) collider.enabled = false;
|
||||
move.moving = false;
|
||||
view.as.idle();
|
||||
|
||||
// 依据下落距离自适应入场时长,保证手感稳定
|
||||
const dropDistance = Math.abs(pos.y - dropToY);
|
||||
const dropDuration = Math.max(0.18, Math.min(0.38, dropDistance / 1200));
|
||||
@@ -167,7 +189,7 @@ export class Hero extends ecs.Entity {
|
||||
if (!node || !node.isValid) return;
|
||||
// 落地后锁定最终位置,切换到落地完成状态
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
hv.playEnd("down");
|
||||
view.playEnd("down");
|
||||
move.moving = true;
|
||||
// 落地后再启用碰撞,避免空中阶段触发伤害结算
|
||||
if (collider) {
|
||||
@@ -177,12 +199,12 @@ export class Hero extends ecs.Entity {
|
||||
}
|
||||
|
||||
// 落地后触发 call 技能
|
||||
if (model.call && model.call.length > 0) {
|
||||
if (model && model.call && model.call.length > 0) {
|
||||
model.call.forEach(uuid => {
|
||||
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||
s_uuid: uuid,
|
||||
heroAttrs: model,
|
||||
heroView: hv,
|
||||
heroView: view,
|
||||
triggerType: 'call'
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user