feat: 音频系统重构 - bg音乐流程修复 + woman语音按点位播放
改动: 1. TouchPositionHandler新增voiceClip字段, 点击时播放对应语音 2. PageController.ShowPage: 首页播放homeBg 3. OnFixationSelected: StopBgMusic()(开场动画开始时停bg) 4. ActivateExperimentObjects: 移除PlayWomanAudioSequence, 保留PlayExperimentBg 5. 新增PlayHomeBg/StopBgMusic/PlayExperimentBg方法 6. 删除_audioManager冗余引用 流程: 首页→homeBg播 → 选固定方式→bg停 → 开场动画→实验bg播 woman语音1→点击point1播, 语音2→point2, 语音3→point3
This commit is contained in:
@@ -122,7 +122,8 @@ public class PageController : MonoBehaviour
|
||||
|
||||
if (_uiManager != null)
|
||||
_uiManager.enabled = (page == Page.Experiment);
|
||||
|
||||
// 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
|
||||
if (page == Page.Home) PlayHomeBg();
|
||||
Debug.Log($"PageController(编辑器预览): 切换到 [{page}]");
|
||||
}
|
||||
#endif
|
||||
@@ -140,7 +141,8 @@ public class PageController : MonoBehaviour
|
||||
if (_experimentPanel != null) _experimentPanel.SetActive(page == Page.Experiment);
|
||||
|
||||
if (_uiManager != null) _uiManager.enabled = (page == Page.Experiment);
|
||||
|
||||
// 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
|
||||
if (page == Page.Home) PlayHomeBg();
|
||||
// 背景音乐控制
|
||||
if (page == Page.Home) PlayHomeBg();
|
||||
else if (page != Page.Experiment) StopBgMusic();
|
||||
@@ -261,7 +263,7 @@ public class PageController : MonoBehaviour
|
||||
Debug.Log($"PageController: GameManager 已设置 Mode=[{gm.CurrentMode}] Fixation=[{gm.CurrentFixationMethod}]");
|
||||
|
||||
// 隐藏所有UI面板,准备播放片头动画
|
||||
HideAllPages();
|
||||
StopBgMusic(); HideAllPages();
|
||||
|
||||
// 找到 OpeningFlowController 播放片头动画
|
||||
var openingFlow = FindObjectOfType<OpeningFlowController>();
|
||||
@@ -304,7 +306,6 @@ public class PageController : MonoBehaviour
|
||||
Debug.Log("PageController: [ActivateExperimentObjects] 显示实验物件");
|
||||
|
||||
PlayExperimentBg();
|
||||
StartCoroutine(PlayWomanAudioSequence());
|
||||
|
||||
var allObjects = FindObjectsOfType<GameObject>(true);
|
||||
foreach (var go in allObjects)
|
||||
@@ -375,3 +376,30 @@ public class PageController : MonoBehaviour
|
||||
[SerializeField] private AudioClip[] _womanClips;
|
||||
private AudioSource _bgAudioSource;
|
||||
}
|
||||
|
||||
private void PlayHomeBg()
|
||||
{
|
||||
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
|
||||
_bgAudioSource.loop = true;
|
||||
_bgAudioSource.playOnAwake = false;
|
||||
if (_homeBgClip != null && _bgAudioSource.clip != _homeBgClip)
|
||||
{
|
||||
_bgAudioSource.clip = _homeBgClip;
|
||||
_bgAudioSource.Play();
|
||||
Debug.Log("PageController: 播放首页背景音乐");
|
||||
}
|
||||
}
|
||||
|
||||
private void StopBgMusic()
|
||||
{
|
||||
if (_bgAudioSource != null && _bgAudioSource.isPlaying) { _bgAudioSource.Stop(); Debug.Log("PageController: 停止背景音乐"); }
|
||||
}
|
||||
|
||||
private void PlayExperimentBg()
|
||||
{
|
||||
StopBgMusic();
|
||||
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
|
||||
_bgAudioSource.loop = true;
|
||||
_bgAudioSource.playOnAwake = false;
|
||||
if (_experimentBgClip != null) { _bgAudioSource.clip = _experimentBgClip; _bgAudioSource.Play(); Debug.Log("PageController: 播放实验背景音乐"); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user