chore: engine, types, demo, and UI updates
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -157,6 +157,7 @@ export type EngineEvent =
|
||||
| 'hotspotUpdate'
|
||||
| 'chapterUnlock'
|
||||
| 'achievementUnlock'
|
||||
| 'battleResultRequest'
|
||||
|
||||
export interface PlayerTreeNode {
|
||||
sceneId: string
|
||||
|
||||
@@ -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": {
|
||||
|
||||
28
src/App.vue
28
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()
|
||||
<BattleResult
|
||||
v-if="store.showBattleResult"
|
||||
:result="store.battleResultData"
|
||||
@continue="store.setShowBattleResult(false)"
|
||||
@continue="onBattleResultContinue"
|
||||
/>
|
||||
<MainMenu
|
||||
v-if="!started || store.gameEnded"
|
||||
|
||||
@@ -46,9 +46,6 @@ export function useGameEngine(videoEls: () => [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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user