using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using Zenject;
using UnityEngine;
using DG.Tweening;

public class MainMenu : MonoBehaviour
{
    [SerializeField] CanvasGroup _splash;
    [SerializeField] UIMenu _warning;

    [Inject] private readonly SceneLoadingService _sceneLoadingService;

    private IEnumerator Start()
    {
        _splash.gameObject.SetActive(true);

        var canvases = GetComponentsInChildren<UIMenu>();
        foreach(var menu in canvases)
            menu.gameObject.SetActive(false);

        yield return new WaitForSeconds(3);

        _warning.gameObject.SetActive(true);

        _splash.DOFade(0, .5f)
            .SetEase(Ease.Linear)
            .OnComplete(() => _splash.gameObject.SetActive(false));
    }

    public async void LoadingNextLevel()
    {
        await _sceneLoadingService.LoadSceneAsync(1);
    }
}
