Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
AudioManager.cs
浏览该文件的文档.
1using Engine;
2using Engine.Audio;
3
4namespace Game {
5 public static class AudioManager {
6 public static float MinAudibleVolume => 0.05f * SettingsManager.SoundsVolume;
7
8 public static void PlaySound(string name, float volume, float pitch, float pan) {
9 PlaySound(name, volume, pitch, pan, Vector3.Zero);
10 }
11
12 public static void PlaySound(string name, float volume, float pitch, float pan, Vector3 vector) {
14 float num = volume * SettingsManager.SoundsVolume;
15 if (num > MinAudibleVolume) {
16 try {
17 SoundBuffer soundBuffer = ContentManager.Get<SoundBuffer>(name);
18 Sound sound = new(soundBuffer, num, ToEnginePitch(pitch), pan, false, true);
19 sound.Play(new Vector3(vector.X, vector.Y, vector.Z));
20 }
21 catch (Exception) {
22 // ignored
23 }
24 }
25 }
26 }
27
28 public static float ToEnginePitch(float pitch) => MathF.Pow(2f, pitch);
29 }
30}
Engine.Vector3 Vector3
static void PlaySound(string name, float volume, float pitch, float pan, Vector3 vector)
static float ToEnginePitch(float pitch)
static float MinAudibleVolume
static void PlaySound(string name, float volume, float pitch, float pan)
static object Get(Type type, string name)
static readonly Vector3 Zero