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

public class ButtonSlot : MonoBehaviour
{
    public Action<int> DelClick;

    [SerializeField] RectTransform mRctContent;
    [SerializeField] GameObject mGobCurrentSign;
    [SerializeField] Image mImgSound;

    private int mIndex;

    private void Awake()
    {
        Button tBtn = GetComponent<Button>();
        UIUtils.BindBtn(tBtn, OnClick);
    }

    public void Init(int pIndex)
    {
        mIndex = pIndex;
        mImgSound.gameObject.SetActive(false);
    }

    public void ShowCurrent(bool pShow)
    {
        mGobCurrentSign.SetActive(pShow);
    }

    public void SetSoundPic(Sprite pSoundPic)
    {
        mImgSound.gameObject.SetActive(true);
        mImgSound.sprite = pSoundPic;
    }

    public void RiseUp()
    {
        Sequence tRiseSeq = DOTween.Sequence();
        tRiseSeq.Append(mRctContent.DOAnchorPosY(70, 0.3f));
        tRiseSeq.AppendInterval(0.5f);
        tRiseSeq.Append(mRctContent.DOAnchorPosY(0, 0.3f));
        tRiseSeq.Play();
    }

    private void OnClick()
    {
        DelClick?.Invoke(mIndex);
    }
}