using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName ="GS", menuName ="Game Sound", order = 1)]
public class GameSound : ScriptableObject {

    public AudioClip clip;

    public float volume = 1.0f;

    public bool randomPitch = false;
    [SerializeField] float _pitch = 1.0f;
    [SerializeField] float pitchMax = 1.0f;

    public float pitch {
        get {
            if(randomPitch) return Random.Range(_pitch, pitchMax);
            else return _pitch;
        }
    }

    public void Play(Vector3 pos) {
        AudioSystem.inst.PlaySound(this, pos);
    }

    public void Play() {
        AudioSystem.inst.PlaySound(this);
    }
}
