using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using VContainer;

public class DeathScreenController
{
    private DeathScreenView _view;

    [Inject] private StartScreenController startScreenController;
    [Inject] private GameScreenController gameScreenController;
    [Inject] private InputReader _inputReader;
    public DeathScreenController(DeathScreenView view)
    {
        _view = view;
        _view.backButton.onClick.AddListener(OnBackBtnClicked);
        _view.rePlayButton.onClick.AddListener(OnReplayBtnClicked);
    }
    public void HideDeathScreen()
    {
        _view.Hide();
    }

    private void OnReplayBtnClicked()
    {
        HideDeathScreen();
        Time.timeScale = 1;
        _inputReader.isBlocked = false;
        SceneManager.LoadScene(0);

        Debug.Log("Game Replayed");
    }

    private void OnBackBtnClicked()
    {
        HideDeathScreen();
        Time.timeScale = 1;
        _inputReader.isBlocked = false;


        SceneManager.LoadScene(0);
    }

    public void ShowDeathScreen(int score, int highscore)
    {
        gameScreenController.HideGameScreen();
        _view.Show(score,highscore);
    }
}
