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

public class MusicPlayerControl : MonoBehaviour
{
    public AudioClip btnClickAudio;
    public AudioClip btnRewardAudio;
    public AudioClip waterAudio;

    public void playBtnAudio()
    {
        if (SaveData.GetIns().isOpenMusic() == 0)
        {
            StartCoroutine(playAtdio(1));
        }
    }

    public void playgetRewardAudio()
    {
        if (SaveData.GetIns().isOpenMusic() == 0)
        {
            StartCoroutine(playAtdio(2));
        }
    }

    public void playColudWaterAudio()
    {
        if (SaveData.GetIns().isOpenMusic() == 0)
        {
            StartCoroutine(playAtdio(3));
        }
    }

    private IEnumerator playAtdio(int type)
    {
        yield return null;
        if (type == 1)
        {
            AudioSource.PlayClipAtPoint(btnClickAudio, transform.position);
        }
        if (type == 2)
        {
            AudioSource.PlayClipAtPoint(btnRewardAudio, transform.position);
        }
        if (type == 3)
        {
            AudioSource.PlayClipAtPoint(waterAudio, transform.position);
        }
    }

}
