35 lines
1.0 KiB
C#

using System.Collections;
using UnityEngine;
namespace GatherAndDefend
{
[CreateAssetMenu(fileName = "Audio", menuName = "AudioTemplate")]
public class AudioTemplate : ScriptableObject
{
[Header("Text")]
public new string name;
[Header("Sound Data")]
[Tooltip("Sound variations if many.")]
public AudioClip[] clips;
public float volume = 1f;
[Tooltip("Max Random pitch change.")]
public float maxRandomPitchChange = 0.02f;
[Tooltip("Max Random volume reduce in percentage. (0.0 to 1.0)")]
public float maxRandomVolumeReducedPercentage = 0.4f;
public AudioClip GetRandomClip()
{
return clips[Random.Range(0, clips.Length)];
}
public float GetRandomPitch()
{
return 1f + Random.Range(-maxRandomPitchChange, maxRandomPitchChange);
}
public float GetVolumeToUse()
{
return volume * (1f - Random.Range(0, maxRandomVolumeReducedPercentage));
}
}
}