using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class SoundBubble : MonoBehaviour
{
    [SerializeField] Image[] mImgBubbles;
    [SerializeField] float mRadius = 120;

    public void Show(int pLevelID)
    {
        Vector2 tStartPos = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.back) * (Vector2.up * mRadius);
        for (int i = 0; i < mImgBubbles.Length; i++)
        {
            mImgBubbles[i].sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetSoundPic(pLevelID, i));
            mImgBubbles[i].color = Color.white;
            mImgBubbles[i].rectTransform.anchoredPosition = Vector2.zero;
            mImgBubbles[i].rectTransform.localScale = Vector3.zero;

            mImgBubbles[i].rectTransform.DOAnchorPos(Quaternion.AngleAxis(120 * i, Vector3.back) * tStartPos, 0.3f).SetEase(Ease.OutBack);
            mImgBubbles[i].rectTransform.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBack);
        }
    }

    public void Hide()
    {
        for (int i = 0; i < mImgBubbles.Length; i++)
        {
            mImgBubbles[i].DOFade(0, 0.8f).SetEase(Ease.Linear);
            mImgBubbles[i].rectTransform.DOScale(Vector3.one * 1.1f, 0.8f).SetEase(Ease.InBack);
        }

        Destroy(gameObject, 1);
    }
}