1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System;
using UnityEngine;
public class EngineBehaviour : MonoBehaviour
{
public AudioClip ElectricSound;
public AudioClip SteamSound;
public float SoundDistance = 5f;
public void PlayElectricSound()
{
if (Constants.ShouldPlaySfx())
{
SoundManager.Instance.PlayDynamicSound("EngineShock" + base.name, this.ElectricSound, false, new DynamicSound.GetDynamicsFunction(this.GetSoundDistance), false);
}
}
public void PlaySteamSound()
{
if (Constants.ShouldPlaySfx())
{
float pitch = FloatRange.Next(0.7f, 1.1f);
SoundManager.Instance.PlayDynamicSound("EngineSteam" + base.name, this.SteamSound, false, delegate(AudioSource p, float d)
{
this.GetSoundDistance(p, d, pitch);
}, false);
}
}
private void GetSoundDistance(AudioSource player, float dt)
{
this.GetSoundDistance(player, dt, 1f);
}
private void GetSoundDistance(AudioSource player, float dt, float pitch)
{
float num = 1f;
if (PlayerControl.LocalPlayer)
{
float num2 = Vector2.Distance(base.transform.position, PlayerControl.LocalPlayer.GetTruePosition());
num = 1f - num2 / this.SoundDistance;
}
player.volume = num * 0.8f;
player.pitch = pitch;
}
}
|