summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/ProjectileAudio.cs
blob: 7390613f0e4a1955d004702a124e6ff0ebc67773 (plain)
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
using UnityEngine;

public class ProjectileAudio : MonoBehaviour
{
	public enum ProjectileType
	{
		Catapult
	}

	public AimbotProjectile target;

	public AudioSource aSource;

	public ProjectileType projectile;

	public float pitchrange = 0.2f;

	private void Start()
	{
		if (target != null)
		{
			target.onHit.AddListener(PlayImpact);
		}
		if (projectile == ProjectileType.Catapult)
		{
			aSource.clip = ThronefallAudioManager.Instance.audioContent.CatapultImpact.GetRandomClip();
		}
		aSource.pitch = Random.Range(1f - pitchrange, 1f + pitchrange);
	}

	private void PlayImpact()
	{
		aSource.Play();
		aSource.transform.parent = null;
		Object.Destroy(aSource.gameObject, aSource.clip.length);
	}
}