v2收尾:手势升级 + 暂停退出 + 结局语音化 + 分支补全 + 12条新音频

gestures.js: 新增长按(1s)、两指长按(暂停)、三指点击(退出),支持多指检测
engine.js: REPLY_COUNT变量、长按重播/状态广播、暂停恢复退出机制、
  选择提示音、结局台词预录音频替换TTS、内容预警+心理热线
story.js: MSG-10/11 follow-up补全down(沉默)选项
index.html: 操作指南添加长按/安全手势、内容预警文字
batch_tts_voxcpm.py: 新增12条台词(结局旁白+系统提示+分支NPC反应)
audio/mp3/tts: 12个VoxCPM2生成的林夏声线MP3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
xsl
2026-05-19 23:22:04 +08:00
co-authored by Claude Opus 4.6
parent e4d1141b4f
commit d03bcb14e4
21 changed files with 929 additions and 326 deletions
+127 -16
View File
@@ -6,6 +6,7 @@
// 新增状态:
// responding — 林夏说话中(打字音效 + 语音播放)
// reacting — NPC反应播放中
// paused — 游戏暂停(两指长按触发)
class GameEngine {
constructor() {
@@ -20,6 +21,7 @@ class GameEngine {
ZHOUNAN_SHARE: false,
SELF_RECORD: false,
UNREAD: 0,
REPLY_COUNT: 0,
};
this.profile = new ProfileTracker();
@@ -35,6 +37,9 @@ class GameEngine {
this._pendingResolve = null; // 用于中断语音播放的 resolve
this._skipRequested = false; // 跳过标志
// 暂停系统
this._pausedState = null; // 暂停前的状态
this.gest = null;
}
@@ -49,10 +54,11 @@ class GameEngine {
idle: '',
notification: '单击 播放 · 双击 跳过',
ringing: '单击 接听 · 左滑 拒接',
playing: '双击 跳过',
playing: '双击 跳过 · 长按 重播',
choosing: '→温暖 ←冷淡 ↑追问 ↓沉默',
responding: '双击 跳过',
reacting: '双击 跳过',
paused: '单击 继续 · 三指点击 退出',
ending: '',
};
el.textContent = H[s] || '';
@@ -65,17 +71,24 @@ class GameEngine {
init(gestureDetector) {
this.gest = gestureDetector;
this.gest
.on('singletap', () => this._onTap())
.on('doubletap', () => this._onDoubleTap())
.on('swipe_left', () => this._onSwipe('left'))
.on('swipe_right', () => this._onSwipe('right'))
.on('swipe_up', () => this._onSwipe('up'))
.on('swipe_down', () => this._onSwipe('down'));
.on('singletap', () => this._onTap())
.on('doubletap', () => this._onDoubleTap())
.on('swipe_left', () => this._onSwipe('left'))
.on('swipe_right', () => this._onSwipe('right'))
.on('swipe_up', () => this._onSwipe('up'))
.on('swipe_down', () => this._onSwipe('down'))
.on('longpress', () => this._onLongPress())
.on('twofinger_longpress', () => this._onPause())
.on('threefinger_tap', () => this._onExit());
}
async start() {
this._queue = [...MESSAGES];
// 内容预警
await this._playVoiceAsync([`${T}/v2_sys_content_warning_wav_v1.mp3`]);
await sleep(1000);
await Snd.startAmbience(AMBIENCE_DEFAULT, { vol: 0.15 });
await sleep(1500);
Snd.startBGM(`${MUS}/lv11_bgm_m1_main_loop_v1.mp3`, { vol: 0.1 });
@@ -334,6 +347,7 @@ class GameEngine {
this.state = 'choosing';
SFX_UI.choiceReady();
Haptic.confirm();
Snd.playVoice([`${T}/v2_sys_wait_reply_wav_v1.mp3`]);
this._startReminder();
}
@@ -369,6 +383,7 @@ class GameEngine {
// 2. 应用状态和画像
if (!choice.isSilence) {
this.msgState[this.currentMsg.id] = 'replied';
this.vars.REPLY_COUNT++;
}
if (choice.state) this._applyState(choice.state);
if (choice.profile) this.profile.add(choice.profile);
@@ -516,6 +531,13 @@ class GameEngine {
_onTap() {
const s = this.state;
// 暂停中 → 恢复
if (s === 'paused') {
this._onResume();
return;
}
if (s === 'ringing') {
this._answerCall(this.currentMsg);
} else if (s === 'notification') {
@@ -530,6 +552,8 @@ class GameEngine {
_onDoubleTap() {
const s = this.state;
if (s === 'paused') return;
if (s === 'ringing') {
this._rejectCall(this.currentMsg);
return;
@@ -579,6 +603,8 @@ class GameEngine {
_onSwipe(dir) {
const s = this.state;
if (s === 'paused') return;
if (s === 'ringing') {
if (dir === 'left') this._rejectCall(this.currentMsg);
else if (dir === 'right') this._answerCall(this.currentMsg);
@@ -602,6 +628,83 @@ class GameEngine {
}
}
// ── 长按:重播 / 状态广播 ──
_onLongPress() {
const s = this.state;
if (s === 'paused' || s === 'ending') return;
Haptic.confirm();
// playing/responding/reacting/choosing → 重播当前消息音频
if ((s === 'playing' || s === 'responding' || s === 'reacting' || s === 'choosing') && this.currentMsg) {
this._interruptVoice();
if (this.currentMsg.audio?.length > 0) {
this._playVoiceAsync(this.currentMsg.audio);
} else if (this.currentMsg.type === 'wechat_text' && this.currentMsg.text) {
TTS.speak(this.currentMsg.text);
}
return;
}
// idle/notification → 广播未读数
TTS.speak(`当前未读${this.vars.UNREAD}条消息`);
}
// ── 暂停 ──
_onPause() {
const s = this.state;
if (s === 'ending' || s === 'paused') return;
this._pausedState = s;
this._interruptVoice();
this._clearReminder();
Haptic.stop();
this.state = 'paused';
Snd.playVoice([`${T}/v2_sys_paused_wav_v1.mp3`]);
}
// ── 恢复 ──
_onResume() {
Snd.stopVoice();
const prev = this._pausedState || 'idle';
this._pausedState = null;
// 语音无法断点续播,根据暂停前状态决定恢复行为
if (prev === 'choosing' && this._currentChoices) {
this.state = 'choosing';
SFX_UI.choiceReady();
Haptic.confirm();
this._startReminder();
} else if (prev === 'notification' || prev === 'ringing') {
this.state = prev;
this._startReminder();
} else {
// playing/responding/reacting → 无法续播,推进到下一条或回到选择
if (this._currentChoices) {
this._enterChoosing(this._currentChoices);
} else {
this._proceedToNext();
}
}
}
// ── 退出 ──
_onExit() {
if (this.state !== 'paused') return;
this._endingTriggered = true;
this._interruptVoice();
// 退出不需要特殊音频,直接返回开始页
setTimeout(() => {
const startEl = document.getElementById('start');
if (startEl) {
startEl.style.opacity = '1';
startEl.style.display = 'flex';
}
}, 2000);
}
// ══════════════════════════════════════════
// 结局系统
// ══════════════════════════════════════════
@@ -611,30 +714,29 @@ class GameEngine {
const v = this.vars;
// 结局E(隐藏)
// 结局E(隐藏)— 优先级 1
if (v.ZHOUNAN_DEPTH >= 2 && v.ZHOUNAN_SHARE &&
(this.profile.label === 'engagement' || this.profile.label === 'nostalgia')) {
return this._triggerEnding('E');
}
// 结局A:妈妈连接 + 自己录音
// 结局A:妈妈连接 + 自己录音 — 优先级 2
if (v.MOM_LINK && v.SELF_RECORD) {
return this._triggerEnding('A');
}
// 结局B:拒了阿哲 + 回了周南
// 结局B:拒了阿哲 + 回了周南 — 优先级 3
if (v.HE_BACK === false && v.ZHOUNAN_DEPTH >= 1) {
return this._triggerEnding('B');
}
// 结局C:全部已读但极少回复
const replied = Object.values(this.msgState).filter(s => s === 'replied').length;
const read = Object.values(this.msgState).filter(s => s !== 'unread').length;
if (read >= MESSAGES.length - 2 && replied <= 2) {
// 结局C:全部已读但极少回复 — 优先级 4
const read = Object.values(this.msgState).filter(s => s !== 'unread').length;
if (read >= MESSAGES.length - 2 && v.REPLY_COUNT <= 2) {
return this._triggerEnding('C');
}
// 结局D(兜底)
// 结局D(兜底)— 优先级 5
this._triggerEnding('D');
}
@@ -659,6 +761,10 @@ class GameEngine {
E: () => this._endingE(),
}[type];
if (fn) await fn();
// 结局后播报心理支持热线
await sleep(3000);
await this._playVoiceAsync([`${T}/v2_sys_hotline_wav_v1.mp3`]);
}
async _endingA() {
@@ -668,13 +774,15 @@ class GameEngine {
await sleep(4000);
SFX_UI.ending();
this._showCaption('明天再说。');
await this._playVoiceAsync([`${T}/v2_ending_a_linxia_wav_v1.mp3`]);
}
async _endingB() {
await sleep(2000);
SFX_UI.ending();
await sleep(1000);
this._showCaption('寄出。');
this._showCaption('寄出去了。');
await this._playVoiceAsync([`${T}/v2_ending_b_linxia_wav_v1.mp3`]);
}
async _endingC() {
@@ -682,6 +790,7 @@ class GameEngine {
SFX_UI.ending();
await sleep(1000);
this._showCaption('今晚就这样。');
await this._playVoiceAsync([`${T}/v2_ending_c_linxia_wav_v1.mp3`]);
}
async _endingD() {
@@ -692,6 +801,7 @@ class GameEngine {
Snd.startAmbience(`${AMB}/amb_dawn_birds_v1.mp3`, { vol: 0.4 });
await sleep(4000);
this._showCaption('早上好。');
await this._playVoiceAsync([`${T}/v2_ending_d_linxia_wav_v1.mp3`]);
}
async _endingE() {
@@ -704,6 +814,7 @@ class GameEngine {
SFX_UI.ending();
await sleep(1000);
this._showCaption('好。');
await this._playVoiceAsync([`${T}/v2_ending_e_linxia_wav_v1.mp3`]);
}
_showCaption(text) {