using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Game;
using Audio;

namespace InteractiveModules
{

    public class MusicDelay : InteractiveModule
    {
        [SerializeField] private GameScreenAsset nextScreen;
        [SerializeField] private MusicManager musicManager;
        [SerializeField] private AudioClip StartClip;
        [SerializeField] private AudioClip EndClip;
        [SerializeField] private float TimeDelay;

        public override void Activate(ScreenController screenController)
        {
            base.Activate(screenController);


            screenController.SetBackgroundColor(ColorType.Grey);
            if (StartClip != null)
            {
                musicManager.MusicPlayer.PlayMusic(StartClip);
            }
        }

        public void Start()
        {
            LeanTween.color(gameObject, Color.clear, TimeDelay);
            Invoke("SwitchScene", TimeDelay);
        }

        public void SwitchScene()
        {
            if (EndClip != null)
            {
                musicManager.MusicPlayer.PlayMusic(EndClip);
            }
            currentScreenController.LoadScreen(nextScreen);
        }
    }
}