perf: 道具支持站位

This commit is contained in:
richarjiang
2025-10-11 14:30:09 +08:00
parent 94fac4f38f
commit 27c30713a9
2 changed files with 17 additions and 7 deletions

View File

@@ -607,7 +607,7 @@ export class PlayerController extends Component {
if (otherCollider.node.name.startsWith('guai_')) {
void this.handleAttack(selfCollider, otherCollider);
} else if (otherCollider.node.name.startsWith('box_')) {
this.handleBoxCollision(otherCollider);
void this.handleBoxCollision(selfCollider, otherCollider);
}
}
@@ -918,7 +918,7 @@ export class PlayerController extends Component {
}, 1); // 延迟1秒显示失败弹窗让玩家死亡动画播放完成
}
private handleBoxCollision(otherCollider: Collider2D) {
private async handleBoxCollision(selfCollider: Collider2D, otherCollider: Collider2D) {
if (!this.player) {
return;
}
@@ -931,6 +931,16 @@ export class PlayerController extends Component {
// 防止重复触发
otherCollider.enabled = false;
this.stopMovement();
await this.alignPlayerForAttack(selfCollider, otherCollider);
if (!this.player || !boxNode.isValid) {
return;
}
this.switchAnimation('stand');
const playerHpNode = this.player.getChildByName('hp');
const boxHpNode = boxNode.getChildByName('hp');