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

namespace UI_and_Audio
{
    public class UIAnimationManager : MonoBehaviour
    {
        [Header("Pulsing")]
        public List<GameObject> scalePulsingGameObjects;
        [Tooltip("StartValue is at 2.0")]
        public float endScalePulseValue;
        public float scalePulseDuration;
        
        [Header("ColorFading")] 
        public List<GameObject> colorPulsingGameObjects;
        public Color destinationColor;
        public float colorPulseDuration;
        
        private void OnEnable()
        {
            foreach (var pulsingObject in scalePulsingGameObjects)
            {
                pulsingObject.transform
                    .DOScale(2.1f, scalePulseDuration)
                    .SetLoops(-1, LoopType.Yoyo)
                    .SetEase(Ease.InOutSine)
                    .SetUpdate(true);
            }

            foreach (var colorPulsingGameObject in colorPulsingGameObjects)
            {
                colorPulsingGameObject.GetComponent<TextMeshProUGUI>()
                    .DOColor(destinationColor, colorPulseDuration)
                    .SetLoops(-1, LoopType.Yoyo)
                    .SetEase(Ease.InOutSine)
                    .SetUpdate(true);
            }
            
        }
    }
}
