using System.Collections;
using StateMachine;
using UnityEngine;

namespace Laptop.States
{
    public class Open : State<LaptopStates>
    {
        private StartGameButton _startGameButton;
        private static readonly int Anim = Animator.StringToHash("IsOpened");
        
        public Open(StartGameButton startGameButton) : base(LaptopStates.Open)
        {
            _startGameButton = startGameButton;
        }

        public override void Enter()
        {
            _startGameButton.Animator.SetBool(Anim, true);
            
            _startGameButton.StartCoroutine(ShowText());
        }
        
        private IEnumerator ShowText()
        {
            yield return new WaitForSeconds(1f);
            _startGameButton.canvas.SetActive(true);
        }

        public override void Exit()
        {
            _startGameButton.canvas.SetActive(false);
        }
    }
}