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

public class AudioManager : MonoBehaviour {

    public AudioSource ambience;
    public AudioSource gameStart;
    public AudioSource gameMusic;
    public AudioSource gameOver;
    public AudioSource cannonShot;
    public AudioSource[] cannonExplosions;
    public AudioSource sharkAppear;
    public AudioSource tentacleAppear;
    public AudioSource gojiAppear;
    public AudioSource cannonMissSplash;
    public AudioSource monsterSurface;

    public static AudioManager Instance;


    void Awake()
    {
        Instance = this;
    }

    public void PlayGameMusic()
    {
        ambience.Play();
        gameStart.Play();
        gameMusic.PlayDelayed(2f);
    }

    public void PlayAmbienceOnly()
    {
        ambience.Play();
    }
        
    public void PlayCannon()
    {
        cannonShot.pitch = Random.Range(0.75f, 1.25f);
        cannonShot.Play();
        var cannonExplosion = cannonExplosions[Random.Range(0, cannonExplosions.Length)];
        cannonExplosion.pitch = Random.Range(0.75f, 1.25f);
        cannonExplosion.Play();
    }

    public void PlayGameOver()
    {
        gameMusic.Stop();
        cannonExplosions[1].Play();
        cannonMissSplash.Play();
        gameOver.PlayDelayed(0.1f);
    }

    public void PlaySharkAppear()
    {
        sharkAppear.Play();
        monsterSurface.Play();
    }

    public void PlayTentacleAppear()
    {
        tentacleAppear.Play();
    }

    public void PlayGojiAppear()
    {
        gojiAppear.Play();
    }

    public void PlaySplash()
    {
        cannonMissSplash.Play();
    }
}
