using Darkmatter.Core;
using UnityEngine;
using VContainer;

namespace Darkmatter.Presentation
{
    public class GameScreenController : IGameScreenController
    {
        GameScreenView gameScreenView;
        [Inject] private IScoreService IscoreService;
        [Inject] private IPauseScreenController IpauseScreenController;
        [Inject] private IInputReader IinputReader;
        [Inject] private IAudioController IaudioController;
        public GameScreenController(GameScreenView _gameScreenView, IScoreService _IscoreService, IPauseScreenController _IpauseScreenController)
        {
            this.gameScreenView = _gameScreenView;
            IscoreService = _IscoreService;
            IpauseScreenController = _IpauseScreenController;
            IscoreService.OnScoreChange += UpdateScore;
            gameScreenView.pauseBtn.onClick.AddListener(OnPauseButtonClicked);
        }



        private void UpdateScore(int score)
        {
            gameScreenView.UpdateScore(score);
        }

        public void ShowGameScreen()
        {
            gameScreenView.Show();
        }

        public void HideGameScreen()
        {
            gameScreenView.Hide();
        }

        public void OnPauseButtonClicked()
        {
            IaudioController.PlayBtnPressedSound();
            Time.timeScale = 0f;
            IinputReader.LockInput();
            IpauseScreenController.ShowPauseScreen();
        }

    }
}
