feat: animate after booped

This commit is contained in:
hypercross 2026-04-05 09:45:01 +08:00
parent 2f0fb2bca8
commit acb2fc82ba
3 changed files with 13 additions and 2 deletions

1
.qwenignore Normal file
View File

@ -0,0 +1 @@
!node_modules

View File

@ -51,6 +51,7 @@ const placeCommand = registry.register( 'place <row:number> <col:number> <player
async function boop(game: BoopGame, row: number, col: number, type: PieceType) {
const booped: string[] = [];
const toRemove = new Set<string>();
await game.produceAsync((state: BoopState) => {
// 按照远离放置位置的方向推动
for (const [dr, dc] of getNeighborPositions()) {
@ -73,8 +74,9 @@ async function boop(game: BoopGame, row: number, col: number, type: PieceType) {
// 检查新位置是否为空或在棋盘外
if (!isInBounds(newRow, newCol)) {
// 棋子被推出棋盘,返回玩家supply
toRemove.add(part.id);
booped.push(part.id);
moveToRegion(part, state.regions.board, state.regions[part.player]);
moveToRegion(part, state.regions.board, state.regions.board, [newRow, newCol]);
} else if (!isCellOccupied(state, newRow, newCol)) {
// 新位置为空,移动过去
booped.push(part.id);
@ -83,6 +85,13 @@ async function boop(game: BoopGame, row: number, col: number, type: PieceType) {
// 如果新位置被占用,则不移动(两个棋子都保持原位)
}
});
await game.produceAsync((state: BoopState) => {
// 移除被吃掉的棋子
for (const partId of toRemove) {
const part = state.pieces[partId];
moveToRegion(part, state.regions.board, state.regions[part.player]);
}
});
return { booped };
}

View File

@ -22,13 +22,14 @@ class BoopPartSpawner implements Spawner<BoopPart, Phaser.GameObjects.Container>
const x = BOARD_OFFSET.x + col * CELL_SIZE + CELL_SIZE / 2;
const y = BOARD_OFFSET.y + row * CELL_SIZE + CELL_SIZE / 2;
this.scene.tweens.add({
const tween = this.scene.tweens.add({
targets: obj,
x: x,
y: y,
duration: 200,
ease: 'Power2',
});
this.scene.addTweenInterruption(tween);
}
onSpawn(part: BoopPart) {