using UnityEngine;
using UnityEngine.Audio;
using System.Collections;

public class AudioController : MonoBehaviour {

    public static AudioController instance { get; private set; }

    public AudioSource inLoop, volcanoBuildup, volcanoAmbience, SFX;
    public AudioClip mumbleClip, clickClip, finalClip, splashClip, runLoopClip, cheerClip, screamClip, meteorClip, fireLoopClip;
    public AudioMixer master;

    public enum audioClips
    {
        mumble,
        click,
        final,
        splash,
        runLoop,
        cheer,
        scream,
        meteor,
        fireLoop
    }

    public enum audioState
    {
        mainLoop,
        volcanoBuildUp,
        volcanoAmbience
    }
    
    void Awake()
    {
        instance = this;
    }
    
    // Use this for initialization
    void Start() {

    }

    public void audioStateChange(audioState state)
    {
        if (state == audioState.volcanoBuildUp)
        {
            volcanoBuildup.Play();
        }
        else if (state == audioState.volcanoAmbience)
        {
            volcanoAmbience.Play();
        }
    }

    public void playSFX(audioClips clip)
    {
        switch (clip)
        {
            case audioClips.mumble:
                SFX.clip = mumbleClip;
                SFX.Play();
                break;
            case audioClips.click:
                SFX.clip = clickClip;
                SFX.Play();
                break;
            case audioClips.final:
                SFX.clip = finalClip;
                SFX.Play();
                break;
            case audioClips.splash:
                SFX.clip = splashClip;
                SFX.loop = false;
                SFX.Play();
                break;
            case audioClips.runLoop:
                SFX.clip = runLoopClip;
                SFX.loop = true;
                SFX.Play();
                break;
            case audioClips.cheer:
                SFX.clip = cheerClip;
                SFX.Play();
                break;
            case audioClips.scream:
                SFX.clip = screamClip;
                SFX.Play();
                break;
            case audioClips.meteor:
                SFX.clip = meteorClip;
                SFX.Play();
                break;
            case audioClips.fireLoop:
                SFX.clip = fireLoopClip;
                SFX.Play();
                break;
        }
    }

}
