using Darkmatter.Core;
using UnityEngine;
using VContainer;
using VContainer.Unity;

namespace Darkmatter.Presentation
{
    public class StartScreenController : IStartable
    {
        private StartScreenView startScreenView;
        [Inject] IGameScreenController gameScreenController;
        [Inject] IInputReader IinputReader;
        [Inject] private IAudioController IaudioController;
        [Inject] private IGameSession IgameSession;
        public StartScreenController(StartScreenView _startScreenView, IGameScreenController _gameScreenController)
        {
            startScreenView = _startScreenView;
            gameScreenController = _gameScreenController;
            startScreenView.tapToStartButton.onClick.AddListener(OnTapToStartButtonClicked);
        }
        public void Start()
        {
            if (IgameSession.showStartScreen)
            {
                startScreenView.Show();
                IinputReader.LockInput();
                IgameSession.showStartScreen = false;
                IgameSession.hasGameStarted = false;
            }
            else
            {
                gameScreenController.ShowGameScreen();
                IgameSession.hasGameStarted = true;
            }

        }

        private void OnTapToStartButtonClicked()
        {
            IaudioController.PlayBtnPressedSound();
            startScreenView.Hide();
            IinputReader.UnlockInput();
            gameScreenController.ShowGameScreen();
            IgameSession.hasGameStarted = true;
        }
    }

}