添加音效
This commit is contained in:
@@ -71,6 +71,16 @@ public class ShockSystem : MonoBehaviour
|
||||
[SerializeField] private float abnormalPanelShakeSpeed = 15f; // 异常状态下面板震动速度
|
||||
[SerializeField] private Color abnormalProgressBarColor = Color.red; // 异常状态下进度条颜色
|
||||
|
||||
[Header("Audio Settings")]
|
||||
[SerializeField] private string chargingEvent = "event:/FollowInput/defib/defib_charging";
|
||||
[SerializeField] private string shockEvent = "event:/FollowInput/defib/defib_shock";
|
||||
[SerializeField] private string defibProgressParam = "defibProgress";
|
||||
[SerializeField] private string shockReverbParam = "reverb";
|
||||
[SerializeField] private float shockFlashDelay = 0.05f; // 声音与闪烁的延迟,可配置
|
||||
[Range(0,1)] public float shockReverb = 0f; // 0=真实,1=梦境
|
||||
private string chargingAudioKey = "defib_charging";
|
||||
private string shockAudioKey = "defib_shock";
|
||||
|
||||
private bool isCharging = false;
|
||||
private float currentProgress = 0f;
|
||||
private float currentLeverAngle = 0f; // 当前杆的角度
|
||||
@@ -191,6 +201,8 @@ public class ShockSystem : MonoBehaviour
|
||||
{
|
||||
isCharging = true;
|
||||
StartCharging();
|
||||
// 开始播放充能音效
|
||||
AibisDream.Kit.AudioManager.Instance.PlaySfx(chargingEvent, chargingAudioKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -258,6 +270,9 @@ public class ShockSystem : MonoBehaviour
|
||||
|
||||
private void ResetProgress()
|
||||
{
|
||||
// 停止充能音效
|
||||
AibisDream.Kit.AudioManager.Instance.StopSfx(chargingAudioKey);
|
||||
|
||||
// 开始进度条平滑下降
|
||||
if (progressTweener != null)
|
||||
{
|
||||
@@ -290,6 +305,10 @@ public class ShockSystem : MonoBehaviour
|
||||
int progressValue = Mathf.FloorToInt(currentProgress);
|
||||
progressBar.CurrentValue = progressValue;
|
||||
|
||||
// 同步defibProgress参数到音频
|
||||
float progressParam = Mathf.Clamp01(currentProgress / progressBar.MaxValue);
|
||||
AibisDream.Kit.AudioManager.Instance.SetSfxParam(chargingAudioKey, defibProgressParam, progressParam);
|
||||
|
||||
// 计算震动强度
|
||||
float currentVibrateStrength = Mathf.Lerp(minVibrateStrength, maxVibrateStrength, progressRatio);
|
||||
|
||||
@@ -356,6 +375,13 @@ public class ShockSystem : MonoBehaviour
|
||||
flashSequence.Kill();
|
||||
}
|
||||
|
||||
// 先播放shock音效
|
||||
AibisDream.Kit.AudioManager.Instance.PlaySfx(shockEvent, shockAudioKey);
|
||||
// 设置reverb参数
|
||||
AibisDream.Kit.AudioManager.Instance.SetSfxParam(shockAudioKey, shockReverbParam, shockReverb);
|
||||
// 延迟shockFlashDelay秒后再闪烁
|
||||
yield return new WaitForSeconds(shockFlashDelay);
|
||||
|
||||
// 获取ECG波形组件
|
||||
var lightSystem = FixSystemCenter.SystemDic.Get<FixLightSystem>();
|
||||
var originalWaveType = lightSystem?.GetCurrentWaveType();
|
||||
|
||||
Reference in New Issue
Block a user