yyl
2025-12-02 45ab7dae9930c2ee227575bf0be1263bd08c81cd
125 战斗 语音加速相关
3个文件已修改
53 ■■■■■ 已修改文件
Main/System/Battle/BattleObject/BattleObject.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/Skill/SkillBase.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/Sound/BattleSoundManager.cs 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleObject/BattleObject.cs
@@ -439,7 +439,7 @@
    public virtual void OnDeath(Action _onDeathAnimationComplete)
    {
        buffMgr.RemoveAllBuff();
        battleField.soundManager.PlayEffectSound(teamHero.heroConfig.DeathSFX);
        battleField.soundManager.PlayEffectSound(teamHero.heroConfig.DeathSFX, false);
        motionBase.PlayDeadAnimation(() =>
        {
            teamHero.isDead = true;
Main/System/Battle/Skill/SkillBase.cs
@@ -237,7 +237,7 @@
        if (skillConfig.SkinllSFX1 != 0)
        {
            battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX1);
            battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX1, false);
        }
        if (caster != null)
@@ -370,7 +370,7 @@
        {
            if (skillConfig.CastDistance < 9999 && skillConfig.SkinllSFX2 != 0)
            {
                battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX2);
                battleField.soundManager.PlayEffectSound(skillConfig.SkinllSFX2, false);
            }
            TurnBack(() =>
Main/System/Battle/Sound/BattleSoundManager.cs
@@ -73,54 +73,25 @@
        CleanupFinishedAudioSources();
    }
    
    /// <summary>
    /// 预热音频(暂时为空,留给移动端优化)
    /// </summary>
    public void PrewarmAudio(params int[] audioIds)
    {
        // TODO: 移动端优化时实现
    }
    /// <summary>
    /// 预热音频(暂时为空,留给移动端优化)
    /// </summary>
    public void PrewarmAudio(List<int> audioIds)
    {
        // TODO: 移动端优化时实现
    }
    /// <summary>
    /// 播放技能音效
    /// </summary>
    /// <param name="audioId">音效ID</param>
    public void PlaySkillSound(int audioId)
    {
        if (audioId <= 0)
        {
            return;
        }
        PlaySound(audioId);
    }
    
    /// <summary>
    /// 播放特效音效
    /// </summary>
    /// <param name="audioId">音效ID</param>
    public void PlayEffectSound(int audioId)
    public void PlayEffectSound(int audioId, bool pitchControl = true)
    {
        if (audioId <= 0)
        {
            return;
        }
        
        PlaySound(audioId);
        PlaySound(audioId, pitchControl);
    }
    
    /// <summary>
    /// 核心播放方法
    /// </summary>
    private void PlaySound(int audioId)
    private void PlaySound(int audioId, bool pitchControl)
    {
        // 检查是否有焦点,无焦点时不播放
        if (!hasFocus)
@@ -152,8 +123,16 @@
        
        // 设置播放速度,使用pitch来控制
        // pitch范围建议在0.5-2.0之间以避免失真
        float pitch = Mathf.Clamp(currentSpeedRatio, 0.5f, 2.0f);
        source.pitch = pitch;
        if (pitchControl)
        {
            float pitch = Mathf.Clamp(currentSpeedRatio, 0.5f, 2.0f);
            source.pitch = pitch;
        }
        else
        {
            source.pitch = 1.0f;
        }
        
        // 播放音效
        source.PlayOneShot(audioClip);