48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using VContainer;
|
|
|
|
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();
|
|
|
|
}
|
|
}
|
|
|
|
public interface IPauseScreenController
|
|
{
|
|
void ShowPauseScreen();
|
|
}
|