diff --git a/engine/core/Engine.ts b/engine/core/Engine.ts
index eb22462..bf84e41 100644
--- a/engine/core/Engine.ts
+++ b/engine/core/Engine.ts
@@ -78,7 +78,7 @@ export class Engine {
this.goToScene(startScene)
}
- private goToScene(scene: SceneNode) {
+ public goToScene(scene: SceneNode) {
this.currentScene = scene
const chapter = this.sceneManager.getChapterBySceneId(scene.id)
@@ -282,6 +282,11 @@ export class Engine {
if (this.loopActive) return
+ if (scene.battleResult) {
+ this.emit('battleResultRequest', scene.battleResult)
+ return
+ }
+
const validChoices = this.getValidChoices(scene)
if (validChoices.length > 0) {
diff --git a/engine/types.ts b/engine/types.ts
index 89a5b6f..25b3d65 100644
--- a/engine/types.ts
+++ b/engine/types.ts
@@ -157,6 +157,7 @@ export type EngineEvent =
| 'hotspotUpdate'
| 'chapterUnlock'
| 'achievementUnlock'
+ | 'battleResultRequest'
export interface PlayerTreeNode {
sceneId: string
diff --git a/public/scenes/demo.json b/public/scenes/demo.json
index 867ec66..1f20118 100644
--- a/public/scenes/demo.json
+++ b/public/scenes/demo.json
@@ -442,18 +442,7 @@
"高清 (720P)": "qte_fail/720p/index.m3u8",
"标清 (480P)": "qte_fail/480p/index.m3u8"
},
- "choices": [
- {
- "text": "继续前进",
- "textKey": "qte_fail.choice.continue",
- "targetScene": "continue_ending"
- },
- {
- "text": "回头",
- "textKey": "qte_fail.choice.back",
- "targetScene": "intro"
- }
- ],
+ "choices": [],
"thumbnail": "qte_fail/thumb.jpg"
},
"desk_detail": {
diff --git a/src/App.vue b/src/App.vue
index e2c9438..ae43038 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -195,6 +195,32 @@ function handleSpeedChange(rate: number) {
currentSpeed.value = rate
}
+function onBattleResultContinue() {
+ store.setShowBattleResult(false)
+ const scene = store.currentScene
+ if (!scene) return
+ if (scene.nextScene) {
+ if (Array.isArray(scene.nextScene)) {
+ for (const route of scene.nextScene) {
+ if (!route.conditions || engine.stateManager.evaluate(route.conditions)) {
+ const next = engine.sceneManager.getScene(route.targetScene)
+ if (next) { engine.goToScene(next) }
+ return
+ }
+ }
+ } else {
+ const next = engine.sceneManager.getScene(scene.nextScene)
+ if (next) { engine.goToScene(next) }
+ return
+ }
+ }
+ if (scene.choices && scene.choices.length > 0) {
+ const first = scene.choices[0]
+ const next = engine.sceneManager.getScene(first.targetScene)
+ if (next) { engine.goToScene(next) }
+ }
+}
+
watch(() => store.currentScene?.id, async (newId) => {
if (!newId) { canSkip.value = false; return }
const scene = store.currentScene
@@ -370,7 +396,7 @@ init()
[HTMLVideoElement | null, HTMLVide
store.clearTimer()
store.clearHotspots()
store.setIsImageScene(scene.type === 'image')
- if (scene.battleResult) {
- store.setBattleResult(scene.battleResult)
- }
store.syncVariables(engine.stateManager.variables)
saveGame(0)
})
@@ -115,6 +112,10 @@ export function useGameEngine(videoEls: () => [HTMLVideoElement | null, HTMLVide
store.resolveQTE(success)
})
+ engine.on('battleResultRequest', (battleResult) => {
+ store.setBattleResult(battleResult)
+ })
+
engine.videoManager.onTimeUpdate((t: number) => {
store.setVideoTime(t)
})