using Darkmatter.Core;
using UnityEngine;
using UnityEngine.SceneManagement;
using VContainer;

namespace Darkmatter.Presentation
{
    public class PauseScreenController : IPauseScreenController
    {
        private PauseScreenView pauseScreenView;
        [Inject] private IInputReader IinputReader;
        [Inject] private IAudioController IaudioController;
        [Inject] private IGameSession IgameSession;

        public PauseScreenController(PauseScreenView _pauseScreenView)
        {
            pauseScreenView = _pauseScreenView;
            pauseScreenView.resumeBtn.onClick.AddListener(OnResumeButtonClicked);
            pauseScreenView.restartBtn.onClick.AddListener(OnRestartButtonClicked);
        }

        public void ShowPauseScreen()
        {
            pauseScreenView.Show();
        }

        private void OnRestartButtonClicked()
        {
            Time.timeScale = 1.0f;
            IinputReader.UnlockInput();
            IaudioController.PlayBtnPressedSound();
            IgameSession.showStartScreen = false;
            SceneManager.LoadScene(0); //Restart This Scene
        }

        private void OnResumeButtonClicked()
        {
            Time.timeScale = 1.0f;
            pauseScreenView.Hide();
            IinputReader.UnlockInput();
            IaudioController.PlayBtnPressedSound();

        }
    }

}
