Skip to content

Commit

Permalink
Merge pull request #87 from our-mini-games/feat-Chinese-chess
Browse files Browse the repository at this point in the history
fix: 动画逻辑处理
  • Loading branch information
libondev authored Jan 2, 2024
2 parents 14ddb49 + 2fbf6b0 commit ec3fc12
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/Chinese-chess/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@ant-design/icons-vue": "^6.1.0",
"@vitejs/plugin-vue": "^4.5.2",
"ant-design-vue": "^3.2.15",
"chinese-chess-service": "^0.0.20",
"chinese-chess-service": "^0.0.21",
"lodash.clonedeep": "^4.5.0",
"socket.io-client": "^4.7.2",
"vue": "^3.2.41"
Expand Down
17 changes: 12 additions & 5 deletions packages/Chinese-chess/src/pages/OnlineGame/GameMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ onMounted(async () => {
})
})
gameInterface.value.on('animation:finished', type => {
if (type === 'check-mate') {
runAnimation(context.value!.currentCamp === Camp.RED ? 'redWin' : 'blackWin')
gameInterface.value?.animations.clear()
console.log(JSON.stringify(context.value!.message))
if (context.value!.message.length > 0) {
const msg = context.value!.message.shift()
if (msg.type === 'animation') {
runAnimation(msg.content)
} else if (msg.type === 'tips') {
runTips(msg.content)
}
}
})
}
Expand Down Expand Up @@ -168,7 +175,7 @@ const handleContextChange = (context: GameContext, gameInterface: ReturnType<typ
if (context.activePiece) {
if (context.players![context.currentCamp]!.id === currentUser.value!.id) {
gameInterface.activePieceAnimation.stop()
gameInterface.activePieceAnimation.run(context.activePiece)
gameInterface.activePieceAnimation.run(context.activePiece, currentUserCamp.value === Camp.BLACK ? Math.PI : 0)
}
} else {
gameInterface.activePieceAnimation.stop()
Expand All @@ -179,8 +186,8 @@ const handleContextChange = (context: GameContext, gameInterface: ReturnType<typ
}
if (context.movePath.length > 0) {
gameInterface.drawCurrentStop(context.movePath[0])
gameInterface.drawLastStop(context.movePath.at(-1)!)
gameInterface.drawCurrentStop(context.movePath.at(-1)!)
gameInterface.drawLastStop(context.movePath[0])
}
if (context.message.length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec3fc12

Please sign in to comment.