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

public class SoundController : MonoBehaviour {
    public static SoundController Current { get; private set; }

    public const string IllegalBuild = "illegal-build-placement";
    public const string Backtrack = "robot-backtrack";
    public const string Advance = "robot_advancing";
    public const string Arrived = "robot_arrived-at-tower";
    public const string Deploy = "tower_deploy";
    public const string PowerOn = "tower_on";
    public const string Shutdown = "tower_shutdown";
    public const string GameOver = "transmission-game-over";

    public AudioClip[] SoundClips;

    void Awake()
    {
        if (Current == null)
            Current = this;
    }

    public AudioSource Source { get; set; }

    // Use this for initialization
    void Start () {
        Source = GetComponent<AudioSource>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
    public void PlaySound(string name, float volume = 1)
    {
        var clip = SoundClips.SingleOrDefault(c => c.name == name);
        if (clip != null) Source.PlayOneShot(clip, volume);

    }
}
